X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSalomeApp%2FSalomeApp_DataModel.cxx;h=e2b9fbef297a4fb62e4e75f2d2acb4dba2c6540e;hb=95c32a3d017f9611ca3519ad1da9c9c23b4e183d;hp=703995a5516ebe2749a1ea1a0468c3749f265422;hpb=238d860366ea8c421aea289df7ff21ba3a565d87;p=modules%2Fgui.git diff --git a/src/SalomeApp/SalomeApp_DataModel.cxx b/src/SalomeApp/SalomeApp_DataModel.cxx index 703995a55..e2b9fbef2 100644 --- a/src/SalomeApp/SalomeApp_DataModel.cxx +++ b/src/SalomeApp/SalomeApp_DataModel.cxx @@ -51,17 +51,26 @@ SUIT_DataObject* SalomeApp_DataModel::BuildTree( const _PTR(SObject)& obj, for ( DataObjectListIterator it( allComponents ); it.current(); ++it ) { SUIT_DataObject* componentObj = it.current(); if ( componentObj->name() == aSName ) { - // mkr : modifications for update of already published in object browser, but not loaded yet components + // mkr : modifications for update of already published in + // object browser, but not loaded yet components + CAM_Application* anApp = dynamic_cast + (SUIT_Session::session()->activeApplication()); + // asv : corresponding DataObjects are DELETED before update (so they are re-built). - CAM_Application* anApp = dynamic_cast( SUIT_Session::session()->activeApplication() ); - if ( anApp && !anApp->module( aSName ) ) { // if module is not loaded, delete it's DataObject - delete componentObj; // delete DataObject and re-create it and all its sub-objects - break; // proceed to build_a_data_object code below + if (anApp && !anApp->module(aSName)) { // if module is not loaded, delete it's DataObject + // jfa: remove children before DataObject deletion + DataObjectList chilren = componentObj->children(/*recursive=*/true); + for (DataObjectListIterator itc (chilren); itc.current(); ++itc) + componentObj->removeChild(itc.current()); + + // delete DataObject itself and re-create it and all its sub-objects + delete componentObj; // don't do anything here, because iterator may be corrupted (deleted object inside it) - } - else - return componentObj; - } + break; // proceed to build_a_data_object code below + } + else + return componentObj; + } } } @@ -69,7 +78,7 @@ SUIT_DataObject* SalomeApp_DataModel::BuildTree( const _PTR(SObject)& obj, new SalomeApp_DataObject ( obj, parent ); _PTR(ChildIterator) it ( study->studyDS()->NewChildIterator( obj ) ); - for ( ; it->More();it->Next() ) { + for ( ; it->More(); it->Next() ) { // don't use shared_ptr here, for Data Object will take // ownership of this pointer _PTR(SObject) aSO( it->Value() ); @@ -247,6 +256,7 @@ SalomeApp_Module* SalomeApp_DataModel::getModule() const //================================================================ SalomeApp_Study* SalomeApp_DataModel::getStudy() const { + if(!root()) return 0; SalomeApp_RootObject* aRoot = dynamic_cast( root()->root() ); if ( !aRoot ) return 0;