From: vsr Date: Fri, 9 Sep 2005 12:06:04 +0000 (+0000) Subject: Fix a bug : popup menus do not work for Python modules when XML menu description... X-Git-Tag: V3_1_0a1~32 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=2b83877edf7de8bb11ab667c286490d0cfd0e8f2;p=modules%2Fgui.git Fix a bug : popup menus do not work for Python modules when XML menu description files are used (obsolete way) --- diff --git a/src/SALOME_PYQT/SALOME_PYQT_GUI/SALOME_PYQT_Module.cxx b/src/SALOME_PYQT/SALOME_PYQT_GUI/SALOME_PYQT_Module.cxx index ee6955223..1d79e16fa 100644 --- a/src/SALOME_PYQT/SALOME_PYQT_GUI/SALOME_PYQT_Module.cxx +++ b/src/SALOME_PYQT/SALOME_PYQT_GUI/SALOME_PYQT_Module.cxx @@ -344,6 +344,37 @@ void SALOME_PYQT_Module::onGUIEvent() PyInterp_Dispatcher::Get()->Exec( new GUIEvent( myInterp, this, id ) ); } +/*! + * Processes GUI action (from context popup menu, only for XML-based actions!) + */ +void SALOME_PYQT_Module::onGUIEvent( int id ) +{ + // perform synchronous request to Python event dispatcher + class GUIEvent : public PyInterp_LockRequest + { + public: + GUIEvent( PyInterp_base* _py_interp, + SALOME_PYQT_Module* _obj, + int _id ) + : PyInterp_LockRequest( _py_interp, 0, true ), // this request should be processed synchronously (sync == true) + myId ( _id ), + myObj ( _obj ) {} + + protected: + virtual void execute() + { + myObj->guiEvent( myId ); + } + + private: + int myId; + SALOME_PYQT_Module* myObj; + }; + + // Posting the request + PyInterp_Dispatcher::Get()->Exec( new GUIEvent( myInterp, this, id ) ); +} + /*! Context popup menu request. Called when user activates popup menu in some window (view, object browser, etc). @@ -1245,7 +1276,7 @@ void SALOME_PYQT_XmlHandler::insertPopupItems( QDomNode& parentNode, QPopupMenu* // -1 action ID is not allowed : it means that attribute is missed in the XML file! // also check if the action with given ID is already created if ( id != -1 ) { - menu->insertItem( anIcon, label, myModule, SLOT( onGUIEvent() ), QKeySequence( accel ), id, pos ); + menu->insertItem( anIcon, label, myModule, SLOT( onGUIEvent(int) ), QKeySequence( accel ), id, pos ); } } else if ( aTagName == "submenu" ) { diff --git a/src/SALOME_PYQT/SALOME_PYQT_GUI/SALOME_PYQT_Module.h b/src/SALOME_PYQT/SALOME_PYQT_GUI/SALOME_PYQT_Module.h index 530e70faa..5377c2969 100644 --- a/src/SALOME_PYQT/SALOME_PYQT_GUI/SALOME_PYQT_Module.h +++ b/src/SALOME_PYQT/SALOME_PYQT_GUI/SALOME_PYQT_Module.h @@ -138,8 +138,9 @@ public slots: ******************************/ public slots: - /* GUI action processing slot */ + /* GUI action processing slots */ void onGUIEvent(); + void onGUIEvent( int ); private: /* internal initizalition */