mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2025-02-21 00:39:42 +05:00
Issue 0020572: EDF 1150 OCC: SIGSEGV when Salome is closing after execution of a GEOM script
This commit is contained in:
parent
418a6b7ea1
commit
9695d3c057
@ -203,17 +203,19 @@ GEOM_Engine::~GEOM_Engine()
|
||||
* GetDocument
|
||||
*/
|
||||
//=============================================================================
|
||||
Handle(TDocStd_Document) GEOM_Engine::GetDocument(int theDocID)
|
||||
Handle(TDocStd_Document) GEOM_Engine::GetDocument(int theDocID, bool force)
|
||||
{
|
||||
Handle(TDocStd_Document) aDoc;
|
||||
if(!_mapIDDocument.IsBound(theDocID)) {
|
||||
if(_mapIDDocument.IsBound(theDocID)) {
|
||||
aDoc = Handle(TDocStd_Document)::DownCast(_mapIDDocument(theDocID));
|
||||
}
|
||||
else if (force) {
|
||||
_OCAFApp->NewDocument("SALOME_GEOM", aDoc);
|
||||
aDoc->SetUndoLimit(_UndoLimit);
|
||||
_mapIDDocument.Bind(theDocID, aDoc);
|
||||
TDataStd_Integer::Set(aDoc->Main(), theDocID);
|
||||
}
|
||||
|
||||
return Handle(TDocStd_Document)::DownCast(_mapIDDocument(theDocID));
|
||||
return aDoc;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
@ -236,17 +238,24 @@ int GEOM_Engine::GetDocID(Handle(TDocStd_Document) theDocument)
|
||||
* GetObject
|
||||
*/
|
||||
//=============================================================================
|
||||
Handle(GEOM_Object) GEOM_Engine::GetObject(int theDocID, char* theEntry)
|
||||
Handle(GEOM_Object) GEOM_Engine::GetObject(int theDocID, char* theEntry, bool force)
|
||||
{
|
||||
Handle(GEOM_Object) anObject;
|
||||
|
||||
TCollection_AsciiString anID = BuildID(theDocID, theEntry);
|
||||
if(_objects.IsBound(anID)) return Handle(GEOM_Object)::DownCast(_objects(anID));
|
||||
|
||||
TDF_Label aLabel;
|
||||
Handle(TDocStd_Document) aDoc = GetDocument(theDocID);
|
||||
TDF_Tool::Label(aDoc->Main().Data(), theEntry, aLabel, Standard_True);
|
||||
Handle(GEOM_Object) anObject = new GEOM_Object(aLabel);
|
||||
|
||||
_objects.Bind(anID, anObject);
|
||||
if (_objects.IsBound(anID)) {
|
||||
anObject = Handle(GEOM_Object)::DownCast(_objects(anID));
|
||||
}
|
||||
else if (force) {
|
||||
Handle(TDocStd_Document) aDoc = GetDocument(theDocID, force);
|
||||
if ( !aDoc.IsNull()) {
|
||||
TDF_Label aLabel;
|
||||
TDF_Tool::Label(aDoc->Main().Data(), theEntry, aLabel, Standard_True);
|
||||
anObject = new GEOM_Object(aLabel);
|
||||
_objects.Bind(anID, anObject);
|
||||
}
|
||||
}
|
||||
|
||||
return anObject;
|
||||
}
|
||||
@ -390,7 +399,9 @@ bool GEOM_Engine::RemoveObject(Handle(GEOM_Object) theObject)
|
||||
if (theObject.IsNull()) return false;
|
||||
|
||||
int aDocID = theObject->GetDocID();
|
||||
|
||||
if(!_mapIDDocument.IsBound(aDocID))
|
||||
return false; // document is closed...
|
||||
|
||||
//Remove an object from the map of available objects
|
||||
TCollection_AsciiString anID = BuildIDFromObject(theObject);
|
||||
if (_objects.IsBound(anID)) _objects.UnBind(anID);
|
||||
|
@ -82,7 +82,7 @@ class GEOM_Engine
|
||||
Standard_EXPORT static GEOM_Engine* GetEngine();
|
||||
|
||||
//Returns the OCAF document by its ID, if document doesn't exists it will be created
|
||||
Standard_EXPORT Handle(TDocStd_Document) GetDocument(int theDocID);
|
||||
Standard_EXPORT Handle(TDocStd_Document) GetDocument(int theDocID, bool force=true);
|
||||
|
||||
//Returns the ID of the given OCAF document
|
||||
Standard_EXPORT int GetDocID(Handle(TDocStd_Document) theDocument);
|
||||
@ -91,7 +91,7 @@ class GEOM_Engine
|
||||
Standard_EXPORT Handle(TDocStd_Application) GetApplication() { return _OCAFApp; }
|
||||
|
||||
//Returns a pointer to GEOM_Object defined by a document and the entry
|
||||
Standard_EXPORT Handle(GEOM_Object) GetObject(int theDocID, char* theEntry);
|
||||
Standard_EXPORT Handle(GEOM_Object) GetObject(int theDocID, char* theEntry, bool force=true);
|
||||
|
||||
//Adds a new object of the type theType in the OCAF document
|
||||
Standard_EXPORT Handle(GEOM_Object) AddObject(int theDocID, int theType);
|
||||
|
@ -147,8 +147,14 @@ Handle(GEOM_Object) GEOM_Object::GetReferencedObject(TDF_Label& theLabel)
|
||||
*/
|
||||
//=============================================================================
|
||||
GEOM_Object::GEOM_Object(TDF_Label& theEntry)
|
||||
: _label(theEntry), _ior("")
|
||||
: _label(theEntry), _ior(""), _docID(-1)
|
||||
{
|
||||
Handle(TDocStd_Document) aDoc = TDocStd_Owner::GetDocument(_label.Data());
|
||||
if(!aDoc.IsNull()) {
|
||||
Handle(TDataStd_Integer) anID;
|
||||
if(aDoc->Main().FindAttribute(TDataStd_Integer::GetID(), anID)) _docID = anID->Get();
|
||||
}
|
||||
|
||||
if(!theEntry.FindAttribute(TDataStd_TreeNode::GetDefaultTreeID(), _root))
|
||||
_root = TDataStd_TreeNode::Set(theEntry);
|
||||
}
|
||||
@ -159,8 +165,14 @@ GEOM_Object::GEOM_Object(TDF_Label& theEntry)
|
||||
*/
|
||||
//=============================================================================
|
||||
GEOM_Object::GEOM_Object(TDF_Label& theEntry, int theType)
|
||||
: _label(theEntry), _ior("")
|
||||
: _label(theEntry), _ior(""), _docID(-1)
|
||||
{
|
||||
Handle(TDocStd_Document) aDoc = TDocStd_Owner::GetDocument(_label.Data());
|
||||
if(!aDoc.IsNull()) {
|
||||
Handle(TDataStd_Integer) anID;
|
||||
if(aDoc->Main().FindAttribute(TDataStd_Integer::GetID(), anID)) _docID = anID->Get();
|
||||
}
|
||||
|
||||
theEntry.ForgetAllAttributes(Standard_True);
|
||||
|
||||
if(!theEntry.FindAttribute(TDataStd_TreeNode::GetDefaultTreeID(), _root))
|
||||
@ -262,13 +274,7 @@ void GEOM_Object::IncrementTic()
|
||||
//=============================================================================
|
||||
int GEOM_Object::GetDocID()
|
||||
{
|
||||
Handle(TDocStd_Document) aDoc = TDocStd_Owner::GetDocument(_label.Data());
|
||||
if(aDoc.IsNull()) return -1;
|
||||
|
||||
Handle(TDataStd_Integer) anID;
|
||||
if(!aDoc->Main().FindAttribute(TDataStd_Integer::GetID(), anID)) return -1;
|
||||
|
||||
return anID->Get();
|
||||
return _docID;
|
||||
}
|
||||
|
||||
|
||||
|
@ -300,6 +300,7 @@ class GEOM_Object : public MMgt_TShared
|
||||
TDF_Label _label;
|
||||
TCollection_AsciiString _ior;
|
||||
TCollection_AsciiString _parameters;
|
||||
int _docID;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -66,11 +66,11 @@
|
||||
// function : GEOM_Gen_i()
|
||||
// purpose : constructor to be called for servant creation.
|
||||
//============================================================================
|
||||
GEOM_Gen_i::GEOM_Gen_i(CORBA::ORB_ptr orb,
|
||||
PortableServer::POA_ptr poa,
|
||||
PortableServer::ObjectId * contId,
|
||||
const char *instanceName,
|
||||
const char *interfaceName) :
|
||||
GEOM_Gen_i::GEOM_Gen_i(CORBA::ORB_ptr orb,
|
||||
PortableServer::POA_ptr poa,
|
||||
PortableServer::ObjectId* contId,
|
||||
const char* instanceName,
|
||||
const char* interfaceName) :
|
||||
Engines_Component_i(orb, poa, contId, instanceName, interfaceName)
|
||||
{
|
||||
_thisObj = this;
|
||||
@ -1587,7 +1587,7 @@ GEOM::GEOM_Object_ptr GEOM_Gen_i::AddSubShape (GEOM::GEOM_Object_ptr theMainShap
|
||||
void GEOM_Gen_i::RemoveObject(GEOM::GEOM_Object_ptr theObject)
|
||||
{
|
||||
CORBA::String_var anEntry = theObject->GetEntry();
|
||||
Handle(GEOM_Object) anObject = _impl->GetObject(theObject->GetStudyID(), anEntry);
|
||||
Handle(GEOM_Object) anObject = _impl->GetObject(theObject->GetStudyID(), anEntry, false);
|
||||
if (anObject.IsNull()) return;
|
||||
_impl->RemoveObject(anObject);
|
||||
return;
|
||||
@ -1808,19 +1808,19 @@ char* GEOM_Gen_i::getObjectInfo(CORBA::Long studyId, const char* entry)
|
||||
//=====================================================================================
|
||||
extern "C"
|
||||
{
|
||||
GEOM_I_EXPORT
|
||||
PortableServer::ObjectId* GEOMEngine_factory(CORBA::ORB*, PortableServer::POA*, PortableServer::ObjectId*, const char*, const char*);
|
||||
|
||||
GEOM_I_EXPORT
|
||||
PortableServer::ObjectId * GEOMEngine_factory(CORBA::ORB_ptr orb,
|
||||
PortableServer::POA_ptr poa,
|
||||
PortableServer::ObjectId * contId,
|
||||
const char *instanceName,
|
||||
const char * interfaceName)
|
||||
/*
|
||||
GEOM_I_EXPORT
|
||||
PortableServer::ObjectId* GEOMEngine_factory(CORBA::ORB*, PortableServer::POA*, PortableServer::ObjectId*, const char*, const char*);
|
||||
*/
|
||||
|
||||
GEOM_I_EXPORT
|
||||
PortableServer::ObjectId* GEOMEngine_factory(CORBA::ORB_ptr orb,
|
||||
PortableServer::POA_ptr poa,
|
||||
PortableServer::ObjectId* contId,
|
||||
const char* instanceName,
|
||||
const char* interfaceName)
|
||||
{
|
||||
GEOM_Gen_i * myGEOM_Gen_i = new GEOM_Gen_i(orb, poa, contId, instanceName, interfaceName);
|
||||
// Don't understand the reason of this register ????
|
||||
// myGEOM_Gen_i->register_name("/myGEOM_Gen"); // NRI : 11/07/2002 : Add for Supervision example
|
||||
return myGEOM_Gen_i->getId();
|
||||
GEOM_Gen_i* myGEOM_Gen_i = new GEOM_Gen_i(orb, poa, contId, instanceName, interfaceName);
|
||||
return myGEOM_Gen_i->getId();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user