From c156adc91db6b53ada8aba498be45d970d56c584 Mon Sep 17 00:00:00 2001 From: imn Date: Fri, 25 Nov 2016 13:24:01 +0300 Subject: [PATCH] Fixed SIGSEGV after recall python command "myStudy." --- idl/SALOMEDS.idl | 21 +++++++++++---------- src/SALOMEDS/SALOMEDS_Study_i.cxx | 27 ++++++++++++++++++++++----- 2 files changed, 33 insertions(+), 15 deletions(-) diff --git a/idl/SALOMEDS.idl b/idl/SALOMEDS.idl index f52389aa1..e300df269 100644 --- a/idl/SALOMEDS.idl +++ b/idl/SALOMEDS.idl @@ -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 See \ref example1 for an example of this method usage in batchmode of %SALOME application. */ 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 diff --git a/src/SALOMEDS/SALOMEDS_Study_i.cxx b/src/SALOMEDS/SALOMEDS_Study_i.cxx index 3f0e83c50..24c8c6626 100644 --- a/src/SALOMEDS/SALOMEDS_Study_i.cxx +++ b/src/SALOMEDS/SALOMEDS_Study_i.cxx @@ -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()); -- 2.39.2