]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
debug IPAL9411: learn OB to completely disconnect from DataObjects upon their removal,
authormsv <msv@opencascade.com>
Wed, 13 Jul 2005 06:18:13 +0000 (06:18 +0000)
committermsv <msv@opencascade.com>
Wed, 13 Jul 2005 06:18:13 +0000 (06:18 +0000)
so that they did not send signal during destroying.

src/ObjBrowser/OB_Browser.cxx
src/ObjBrowser/OB_Browser.h

index dd6033a40a44bcdc7632fcf611e36dc13b5fb8c0..129503b0d782dd4fba4316da5b0b35a7591bede6 100755 (executable)
@@ -179,6 +179,7 @@ void OB_Browser::setRootObject( SUIT_DataObject* theRoot )
   if ( theRoot )
     curObj = storeState( selObjs, openObjs, selKeys, openKeys, curKey );
 
+  removeConnections( myRoot );
   if ( myRoot != theRoot && isAutoDeleteObjects() )
     delete myRoot;
 
@@ -505,7 +506,7 @@ void OB_Browser::updateTree( SUIT_DataObject* obj )
 
 void OB_Browser::replaceTree( SUIT_DataObject* src, SUIT_DataObject* trg )
 {
-  if ( !src || !trg || src->root() != getRootObject() )
+  if ( !src || !trg || src == trg || src->root() != getRootObject() )
     return;
 
   DataObjectKey curKey;
@@ -521,7 +522,8 @@ void OB_Browser::replaceTree( SUIT_DataObject* src, SUIT_DataObject* trg )
 
   src->setParent( 0 );
 
-  if ( src != trg && isAutoDeleteObjects() )
+  removeConnections( src );
+  if ( isAutoDeleteObjects() )
     delete src;
 
   if ( parent && pos != -1 )
@@ -732,6 +734,7 @@ void OB_Browser::removeReferences( QListViewItem* item )
     return;
 
   SUIT_DataObject* obj = dataObject( item );
+  obj->disconnect( this, SLOT( onDestroyed( SUIT_DataObject* ) ) );
   myItems.remove( obj );
 
   QListViewItem* i = item->firstChild();
@@ -756,6 +759,20 @@ void OB_Browser::createConnections( SUIT_DataObject* obj )
     it.current()->connect( this, SLOT( onDestroyed( SUIT_DataObject* ) ) );
 }
 
+void OB_Browser::removeConnections( SUIT_DataObject* obj )
+{
+  if ( !obj )
+    return;
+
+  DataObjectList childList;
+  obj->children( childList, true );
+
+  childList.prepend( obj );
+
+  for ( DataObjectListIterator it( childList ); it.current(); ++it )
+    it.current()->disconnect( this, SLOT( onDestroyed( SUIT_DataObject* ) ) );
+}
+
 SUIT_DataObject* OB_Browser::storeState( DataObjectMap& selObjs, DataObjectMap& openObjs,
                                          DataObjectKeyMap& selKeys, DataObjectKeyMap& openKeys,
                                          DataObjectKey& curKey ) const
@@ -1021,6 +1038,7 @@ void OB_Browser::removeObject( SUIT_DataObject* obj, const bool autoUpd )
 
   QListViewItem* item = listViewItem( obj );
 
+  obj->disconnect( this, SLOT( onDestroyed( SUIT_DataObject* ) ) );
   myItems.remove( obj );
 
   if ( obj == myRoot )
index 5e5adeccd58ca2ef60b7e122ac0fd8957e5cb3ba..3d2ebb1c314810857656d5690d8a76e9ea930a32 100755 (executable)
@@ -131,6 +131,7 @@ private:
   void              openBranch( QListViewItem*, const int );
 
   void              removeReferences( QListViewItem* );
+  void              removeConnections( SUIT_DataObject* );
   void              createConnections( SUIT_DataObject* );
   void              removeObject( SUIT_DataObject*, const bool = true );