From c0088afdcc83363b53264452a25013eab6264fde Mon Sep 17 00:00:00 2001 From: vsr Date: Sat, 29 Dec 2012 13:31:13 +0000 Subject: [PATCH] 0022006: [CEA 727] Restore GUI state makes SALOME crash --- src/LightApp/LightApp_Application.cxx | 9 +++++++++ src/SUIT/SUIT_Selector.cxx | 17 +++++++++++++---- src/SUIT/SUIT_Selector.h | 2 ++ 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/LightApp/LightApp_Application.cxx b/src/LightApp/LightApp_Application.cxx index 83ff7cbe1..0c11ef825 100644 --- a/src/LightApp/LightApp_Application.cxx +++ b/src/LightApp/LightApp_Application.cxx @@ -3476,6 +3476,15 @@ void LightApp_Application::removeViewManager( SUIT_ViewManager* vm ) if (aStudy ) aStudy->removeViewMgr(vm->getGlobalId()); + LightApp_SelectionMgr* selMgr = selectionMgr(); + QList selectors; + selMgr->selectors( selectors ); + foreach( SUIT_Selector* selector, selectors ) { + if ( selector->owner() == vm->getViewModel() ) { + delete selector; + } + } + STD_Application::removeViewManager( vm ); // IPAL22894: Crash on closing OCC view diff --git a/src/SUIT/SUIT_Selector.cxx b/src/SUIT/SUIT_Selector.cxx index 29881c37e..2fc3a8725 100755 --- a/src/SUIT/SUIT_Selector.cxx +++ b/src/SUIT/SUIT_Selector.cxx @@ -76,10 +76,10 @@ void SUIT_Selector::Destroyer::setSelector( SUIT_Selector* s ) */ SUIT_Selector::SUIT_Selector( SUIT_SelectionMgr* selMgr, QObject* parent ) : mySelMgr( selMgr ), -myBlock( false ), -myEnabled( true ), -myAutoBlock( true ), -myDestroyer( 0 ) + myBlock( false ), + myEnabled( true ), + myAutoBlock( true ), + myDestroyer( 0 ) { if ( selMgr ) selMgr->installSelector( this ); @@ -100,6 +100,7 @@ SUIT_Selector::~SUIT_Selector() { myDestroyer->setSelector( 0 ); delete myDestroyer; + myDestroyer = 0; } } @@ -196,3 +197,11 @@ void SUIT_Selector::selectionModes( QList& lst ) const if ( selectionMgr() ) selectionMgr()->selectionModes( lst ); } + +/*! + Get owner of this selector. + */ +QObject* SUIT_Selector::owner() const +{ + return myDestroyer ? myDestroyer->parent() : 0; +} diff --git a/src/SUIT/SUIT_Selector.h b/src/SUIT/SUIT_Selector.h index 775d01fb1..76f1da650 100755 --- a/src/SUIT/SUIT_Selector.h +++ b/src/SUIT/SUIT_Selector.h @@ -64,6 +64,8 @@ public: bool hasSelectionMode( const int ) const; void selectionModes( QList& ) const; + QObject* owner() const; + protected: void selectionChanged(); virtual void getSelection( SUIT_DataOwnerPtrList& ) const = 0; -- 2.39.2