From: mzn Date: Wed, 15 Sep 2010 11:36:06 +0000 (+0000) Subject: Correction: remove destroyed actions from the actions list. X-Git-Tag: V5_1_5a1~8 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=de3ae0ddca41594f4e85214ce637c99507ee2c96;p=modules%2Fgui.git Correction: remove destroyed actions from the actions list. --- diff --git a/src/SUIT/SUIT_ShortcutMgr.cxx b/src/SUIT/SUIT_ShortcutMgr.cxx index ab5afccbc..44eb8a950 100644 --- a/src/SUIT/SUIT_ShortcutMgr.cxx +++ b/src/SUIT/SUIT_ShortcutMgr.cxx @@ -119,9 +119,11 @@ void SUIT_ShortcutMgr::processAction( QtxAction* action ) if ( !shortcutActionName.isEmpty() ) { // Add action to the actions map - QList actions = myShortcutActions.values( shortcutActionName ); - if ( !actions.contains(action) ) - myShortcutActions.insertMulti( shortcutActionName, action ); + if ( !myShortcutActions.contains( shortcutActionName, action ) ) { + myShortcutActions.insert( shortcutActionName, action ); + connect( action, SIGNAL( destroyed( QObject* ) ), + this, SLOT ( onActionDestroyed( QObject* ) ) ); + } QKeySequence keySeq = getShortcutByActionName( shortcutActionName ); action->setShortcut( keySeq ); @@ -168,3 +170,18 @@ void SUIT_ShortcutMgr::updateShortcuts() action->setShortcut( keySeq ); } } + +/*! + \brief Called when the corresponding action is destroyed. + + Removes destroyed action from the actions list. + + \param obj action being destroyed +*/ +void SUIT_ShortcutMgr::onActionDestroyed( QObject* obj ) +{ + QtxAction* anAction = (QtxAction*)obj; + + if ( anAction ) + myShortcutActions.remove( anAction->shortcutActionName(), anAction ); +} diff --git a/src/SUIT/SUIT_ShortcutMgr.h b/src/SUIT/SUIT_ShortcutMgr.h index e620db8e6..eafd854e2 100644 --- a/src/SUIT/SUIT_ShortcutMgr.h +++ b/src/SUIT/SUIT_ShortcutMgr.h @@ -26,7 +26,7 @@ #include "SUIT.h" #include -#include +#include class QtxAction; @@ -42,6 +42,7 @@ class QKeySequence; */ class SUIT_EXPORT SUIT_ShortcutMgr: public QObject { + Q_OBJECT public: static void Init(); static SUIT_ShortcutMgr* getShortcutMgr(); @@ -53,6 +54,9 @@ protected: SUIT_ShortcutMgr(); virtual ~SUIT_ShortcutMgr(); +private slots: + void onActionDestroyed( QObject* ); + private: virtual bool eventFilter( QObject* o, QEvent* e ); @@ -61,7 +65,7 @@ private: private: static SUIT_ShortcutMgr* myShortcutMgr; - QMap myShortcutActions; + QMultiMap myShortcutActions; }; #if defined WIN32