From 9912133bfc94786da1b81666bf944de14d29cd77 Mon Sep 17 00:00:00 2001 From: ptv Date: Wed, 9 Nov 2005 14:51:24 +0000 Subject: [PATCH] remove dead widget container from windows map --- src/LightApp/LightApp_Application.cxx | 19 ++++++++++++++++++- src/LightApp/LightApp_Application.h | 2 ++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/LightApp/LightApp_Application.cxx b/src/LightApp/LightApp_Application.cxx index dac8a5223..3fc89457e 100644 --- a/src/LightApp/LightApp_Application.cxx +++ b/src/LightApp/LightApp_Application.cxx @@ -850,7 +850,9 @@ void LightApp_Application::addWindow( QWidget* wid, const int flag, const int st QMap winMap; currentWindows( winMap ); - myWindows.insert( flag, new LightApp_WidgetContainer( flag, desktop() ) ); + LightApp_WidgetContainer* newWC = new LightApp_WidgetContainer( flag, desktop() ); + connect( newWC, SIGNAL( destroyed ( QObject* ) ), this, SLOT( onWCDestroyed( QObject* ) ) ); + myWindows.insert( flag, newWC ); if ( winMap.contains( flag ) ) desktop()->moveDockWindow( myWindows[flag], (Dock)winMap[flag] ); @@ -1838,3 +1840,18 @@ SUIT_Accel* LightApp_Application::accel() const { return myAccel; } + +/*! remove dead widget container from map */ +void LightApp_Application::onWCDestroyed( QObject* ob ) +{ + // remove destroyed widget container from windows map + for ( WindowMap::ConstIterator itr = myWindows.begin(); itr != myWindows.end(); ++itr ) + { + if ( itr.data() != ob ) + continue; + + int key = itr.key(); + myWindows.remove( key ); + break; + } +} diff --git a/src/LightApp/LightApp_Application.h b/src/LightApp/LightApp_Application.h index cfb459fba..ef00439de 100644 --- a/src/LightApp/LightApp_Application.h +++ b/src/LightApp/LightApp_Application.h @@ -141,6 +141,8 @@ protected slots: void onStudySaved( SUIT_Study* ); void onStudyClosed( SUIT_Study* ); + void onWCDestroyed( QObject* ); + private slots: void onSelection(); void onRefresh(); -- 2.39.2