From 39e636249cebadf080424a792689f3b9d4c52e4e Mon Sep 17 00:00:00 2001 From: imn Date: Thu, 17 Nov 2016 16:36:16 +0300 Subject: [PATCH] Fixed SIGSEGV after execute python command "myStudy.Clear()" --- src/SALOMEDS/SALOMEDS_Study_i.cxx | 65 ++++++++++++++++--------------- 1 file changed, 33 insertions(+), 32 deletions(-) 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; } -- 2.39.2