From 75504b35e2c918c45cd3b5f51ca4f1d744fa1ba3 Mon Sep 17 00:00:00 2001 From: msv Date: Wed, 13 Jul 2005 06:18:13 +0000 Subject: [PATCH] debug IPAL9411: learn OB to completely disconnect from DataObjects upon their removal, so that they did not send signal during destroying. --- src/ObjBrowser/OB_Browser.cxx | 22 ++++++++++++++++++++-- src/ObjBrowser/OB_Browser.h | 1 + 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/ObjBrowser/OB_Browser.cxx b/src/ObjBrowser/OB_Browser.cxx index dd6033a40..129503b0d 100755 --- a/src/ObjBrowser/OB_Browser.cxx +++ b/src/ObjBrowser/OB_Browser.cxx @@ -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 ) diff --git a/src/ObjBrowser/OB_Browser.h b/src/ObjBrowser/OB_Browser.h index 5e5adeccd..3d2ebb1c3 100755 --- a/src/ObjBrowser/OB_Browser.h +++ b/src/ObjBrowser/OB_Browser.h @@ -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 ); -- 2.39.2