From: imn Date: Thu, 17 Nov 2016 13:36:16 +0000 (+0300) Subject: Fixed SIGSEGV after execute python command "myStudy.Clear()" X-Git-Tag: Before_python3_27062017~1^2~23 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=39e636249cebadf080424a792689f3b9d4c52e4e;p=modules%2Fkernel.git Fixed SIGSEGV after execute python command "myStudy.Clear()" --- diff --git a/src/SALOMEDS/SALOMEDS_Study_i.cxx b/src/SALOMEDS/SALOMEDS_Study_i.cxx index 5c1337f18..51f96ea78 100644 --- a/src/SALOMEDS/SALOMEDS_Study_i.cxx +++ b/src/SALOMEDS/SALOMEDS_Study_i.cxx @@ -292,11 +292,6 @@ void SALOMEDS_Study_i::Clear() PortableServer::ObjectId_var anObjectId = poa->servant_to_id(_builder); poa->deactivate_object(anObjectId.in()); _builder->_remove_ref(); - - _impl->Clear(); - _impl->setNotifier(0); - delete _notifier; - delete _genObjRegister; SALOMEDS::Locker lock; @@ -304,37 +299,38 @@ void SALOMEDS_Study_i::Clear() throw SALOMEDS::Study::StudyInvalidReference(); RemovePostponed(-1); - - SALOMEDS::SComponentIterator_var itcomponent = NewComponentIterator(); - for (; itcomponent->More(); itcomponent->Next()) { - SALOMEDS::SComponent_var sco = itcomponent->Value(); - CORBA::String_var compodatatype=sco->ComponentDataType(); - MESSAGE ( "Look for an engine for data type :"<< compodatatype); - // if there is an associated Engine call its method for closing - CORBA::String_var IOREngine; - if (sco->ComponentIOR(IOREngine)) { - // we have found the associated engine to write the data - MESSAGE ( "We have found an engine for data type :"<< compodatatype); - //_narrow can throw a corba exception - try { - CORBA::Object_var obj = _orb->string_to_object(IOREngine); - if (!CORBA::is_nil(obj)) { - SALOMEDS::Driver_var anEngine = SALOMEDS::Driver::_narrow(obj) ; - if (!anEngine->_is_nil()) { - SALOMEDS::unlock(); - anEngine->Close(sco); - SALOMEDS::lock(); + if (_impl->GetDocument()) { + SALOMEDS::SComponentIterator_var itcomponent = NewComponentIterator(); + for (; itcomponent->More(); itcomponent->Next()) { + SALOMEDS::SComponent_var sco = itcomponent->Value(); + CORBA::String_var compodatatype=sco->ComponentDataType(); + MESSAGE ( "Look for an engine for data type :"<< compodatatype); + // if there is an associated Engine call its method for closing + CORBA::String_var IOREngine; + if (sco->ComponentIOR(IOREngine)) { + // we have found the associated engine to write the data + MESSAGE ( "We have found an engine for data type :"<< compodatatype); + //_narrow can throw a corba exception + try { + CORBA::Object_var obj = _orb->string_to_object(IOREngine); + if (!CORBA::is_nil(obj)) { + SALOMEDS::Driver_var anEngine = SALOMEDS::Driver::_narrow(obj) ; + if (!anEngine->_is_nil()) { + SALOMEDS::unlock(); + anEngine->Close(sco); + SALOMEDS::lock(); + } } - } - } - catch (CORBA::Exception&) { + } + catch (CORBA::Exception&) { + } } + sco->UnRegister(); } - sco->UnRegister(); - } - //Does not need any more this iterator - itcomponent->UnRegister(); + //Does not need any more this iterator + itcomponent->UnRegister(); + } // Notify GUI that study is cleared SALOME_NamingService *aNamingService = KERNEL::getNamingService(); @@ -349,6 +345,11 @@ void SALOMEDS_Study_i::Clear() SALOMEDS::lock(); } + _impl->Clear(); + _impl->setNotifier(0); + delete _notifier; + delete _genObjRegister; + _closed = true; }