Salome HOME
Fixed SIGSEGV after recall python command "myStudy.<command>"
authorimn <imn@opencascade.com>
Fri, 25 Nov 2016 10:24:01 +0000 (13:24 +0300)
committerimn <imn@opencascade.com>
Fri, 25 Nov 2016 10:24:01 +0000 (13:24 +0300)
idl/SALOMEDS.idl
src/SALOMEDS/SALOMEDS_Study_i.cxx

index f52389aa1ea558c1c814204f0d02ca63258d7554..e300df269ba3ac9609ed4fddc84a9c3ef5453b17 100644 (file)
@@ -603,11 +603,11 @@ Searches for a definite %SObject with a definite GUID and returns True if it fin
     
 /*! \brief Clear a study object
 */
-    void Clear();
+    void Clear() raises(StudyInvalidReference);
 
 /*! \brief Initialization a study object
 */
-    void Init();
+    void Init() raises(StudyInvalidReference);
     
 /*! \brief Open a study by url
 
@@ -621,14 +621,14 @@ Searches for a definite %SObject with a definite GUID and returns True if it fin
     Saves a study.
     \param theMultiFile If this parameter is True the study will be saved in several files.
 */
-    boolean Save(in boolean theMultiFile);
+    boolean Save(in boolean theMultiFile) raises(StudyInvalidReference);
     
 /*! \brief Saving a study in a ASCII file (or files).
 
     Saves a study in an ASCII format file (or files).
     \param theMultiFile If this parameter is True the study will be saved in several files.
 */
-    boolean  SaveASCII(in boolean theMultiFile);
+    boolean  SaveASCII(in boolean theMultiFile) raises(StudyInvalidReference);
 /*! \brief Saving the study in a specified HDF file (or files).
 
     Saves the study in a specified file (or files).
@@ -639,7 +639,8 @@ Searches for a definite %SObject with a definite GUID and returns True if it fin
 <em>See \ref example1 for an example of this method usage in batchmode of %SALOME application.</em>
 */
     boolean  SaveAs(in URLPath aUrl, // if the file already exists
-                    in boolean theMultiFile); // overwrite (as option)
+                    in boolean theMultiFile) // overwrite (as option)
+                    raises(StudyInvalidReference); 
 /*! \brief Saving the study in a specified ASCII file (or files).
 
     Saves the study in a specified ASCII file (or files).
@@ -649,22 +650,22 @@ Searches for a definite %SObject with a definite GUID and returns True if it fin
     \param theMultiFile If this parameter is True the study will be saved in several files.
 */
     boolean  SaveAsASCII(in URLPath aUrl, // if the file already exists
-                         in boolean theMultiFile); // overwrite (as option)
-
+                         in boolean theMultiFile) // overwrite (as option)
+                         raises(StudyInvalidReference); 
 /*!
     Returns True, if the given %SObject can be copied to the clipboard.
 */
-    boolean CanCopy(in SObject theObject);
+    boolean CanCopy(in SObject theObject) raises(StudyInvalidReference);
 /*!
     Returns True, if the given %SObject is copied to the clipboard.
     \param theObject The %SObject which will be copied
 */
-    boolean Copy(in SObject theObject);
+    boolean Copy(in SObject theObject) raises(StudyInvalidReference);
 /*!
     Returns True, if the object from the clipboard can be pasted to the given %SObject.
     \param theObject The %SObject stored in the clipboard.
 */
-    boolean CanPaste(in SObject theObject);
+    boolean CanPaste(in SObject theObject) raises(StudyInvalidReference);
 /*!
     Returns the %SObject in which the object from the clipboard was pasted to.
     \param theObject The %SObject which will be pasted
index 3f0e83c50e9c7bac00dccc0622fbf47007bcf4b5..24c8c6626fa5c82a3c4ef61343fbf8fac5838ef1 100644 (file)
@@ -235,6 +235,7 @@ SALOMEDS_Study_i::SALOMEDS_Study_i(CORBA::ORB_ptr orb)
   _orb     = CORBA::ORB::_duplicate(orb);
   _impl    = new SALOMEDSImpl_Study();
   _factory = new SALOMEDS_DriverFactory_i(_orb);
+  _closed  = true;
 
   Init();
 }
@@ -261,6 +262,9 @@ void SALOMEDS_Study_i::Init()
   if ( !_impl->GetDocument() )
     _impl->Init();
 
+  if (!_closed)
+    throw SALOMEDS::Study::StudyInvalidReference();
+
   _builder        = new SALOMEDS_StudyBuilder_i(_impl->NewBuilder(), _orb);  
   _notifier       = new SALOMEDS::Notifier(_orb);
   _genObjRegister = new SALOMEDS::GenObjRegister(_orb);
@@ -293,18 +297,17 @@ void SALOMEDS_Study_i::Init()
 //============================================================================
 void SALOMEDS_Study_i::Clear()
 {
+  SALOMEDS::Locker lock;
+  if (_closed)
+    throw SALOMEDS::Study::StudyInvalidReference();
   //delete the builder servant
   PortableServer::POA_var poa=_builder->_default_POA();
   PortableServer::ObjectId_var anObjectId = poa->servant_to_id(_builder);
   poa->deactivate_object(anObjectId.in());
   _builder->_remove_ref();
 
-  SALOMEDS::Locker lock;
-
-  if (_closed)
-    throw SALOMEDS::Study::StudyInvalidReference();
-
   RemovePostponed(-1);
+
   if (_impl->GetDocument()) {
     SALOMEDS::SComponentIterator_var itcomponent = NewComponentIterator();
     for (; itcomponent->More(); itcomponent->Next()) {
@@ -390,12 +393,16 @@ bool SALOMEDS_Study_i::Open(const char* aUrl)
 CORBA::Boolean SALOMEDS_Study_i::Save(CORBA::Boolean theMultiFile)
 {
   SALOMEDS::Locker lock;
+  if (_closed)
+    throw SALOMEDS::Study::StudyInvalidReference();
   return _impl->Save(_factory, theMultiFile);
 }
 
 CORBA::Boolean SALOMEDS_Study_i::SaveASCII(CORBA::Boolean theMultiFile)
 {
   SALOMEDS::Locker lock;
+  if (_closed)
+    throw SALOMEDS::Study::StudyInvalidReference();
   return _impl->SaveASCII(_factory, theMultiFile);
 }
 
@@ -407,12 +414,16 @@ CORBA::Boolean SALOMEDS_Study_i::SaveASCII(CORBA::Boolean theMultiFile)
 CORBA::Boolean SALOMEDS_Study_i::SaveAs(const char* aUrl, CORBA::Boolean theMultiFile)
 {
   SALOMEDS::Locker lock;
+  if (_closed)
+    throw SALOMEDS::Study::StudyInvalidReference();
   return _impl->SaveAs(std::string(aUrl), _factory, theMultiFile);
 }
 
 CORBA::Boolean SALOMEDS_Study_i::SaveAsASCII(const char* aUrl, CORBA::Boolean theMultiFile)
 {
   SALOMEDS::Locker lock;
+  if (_closed)
+    throw SALOMEDS::Study::StudyInvalidReference();
   return _impl->SaveAsASCII(std::string(aUrl), _factory, theMultiFile);
 }
 
@@ -424,6 +435,8 @@ CORBA::Boolean SALOMEDS_Study_i::SaveAsASCII(const char* aUrl, CORBA::Boolean th
 CORBA::Boolean SALOMEDS_Study_i::CanCopy(SALOMEDS::SObject_ptr theObject)
 {
   SALOMEDS::Locker lock;
+  if (_closed)
+    throw SALOMEDS::Study::StudyInvalidReference();
 
   CORBA::String_var anID = theObject->GetID();
   SALOMEDSImpl_SObject anObject = _impl->GetSObject(anID.in());
@@ -442,6 +455,8 @@ CORBA::Boolean SALOMEDS_Study_i::CanCopy(SALOMEDS::SObject_ptr theObject)
 CORBA::Boolean SALOMEDS_Study_i::Copy(SALOMEDS::SObject_ptr theObject)
 {
   SALOMEDS::Locker lock;
+  if (_closed)
+    throw SALOMEDS::Study::StudyInvalidReference();
 
   CORBA::String_var anID = theObject->GetID();
   SALOMEDSImpl_SObject anObject = _impl->GetSObject(anID.in());
@@ -460,6 +475,8 @@ CORBA::Boolean SALOMEDS_Study_i::Copy(SALOMEDS::SObject_ptr theObject)
 CORBA::Boolean SALOMEDS_Study_i::CanPaste(SALOMEDS::SObject_ptr theObject)
 {
   SALOMEDS::Locker lock;
+  if (_closed)
+    throw SALOMEDS::Study::StudyInvalidReference();
 
   CORBA::String_var anID = theObject->GetID();
   SALOMEDSImpl_SObject anObject = _impl->GetSObject(anID.in());