X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2FSALOME_PYQT%2FSALOME_PYQT_GUILight%2FSALOME_PYQT_PyModule.cxx;h=b4eba060a54045c450310f9da1e166019640ad82;hb=75458e7ab6e5345b70f338764a757011230931ac;hp=25120ac5e29de82acc743e04f563e4a921f9a54d;hpb=bb8609caf7881d966fbb88dec0a7822736da93f5;p=modules%2Fgui.git diff --git a/src/SALOME_PYQT/SALOME_PYQT_GUILight/SALOME_PYQT_PyModule.cxx b/src/SALOME_PYQT/SALOME_PYQT_GUILight/SALOME_PYQT_PyModule.cxx index 25120ac5e..b4eba060a 100644 --- a/src/SALOME_PYQT/SALOME_PYQT_GUILight/SALOME_PYQT_PyModule.cxx +++ b/src/SALOME_PYQT/SALOME_PYQT_GUILight/SALOME_PYQT_PyModule.cxx @@ -962,6 +962,58 @@ bool PyModuleHelper::deactivate( SUIT_Study* study ) return true; } +/*! + \brief Close of the module. + + This function is usually used in order to close the module's + specific menus and toolbars and perform other such actions + required when the module is closed. +*/ +void PyModuleHelper::modelClosed( SUIT_Study* study ) +{ + FuncMsg fmsg( "PyModuleHelper::modelClosed()" ); + + class StudyClosedReq : public PyInterp_LockRequest + { + public: + StudyClosedReq( PyInterp_Interp* _py_interp, + PyModuleHelper* _helper, + SUIT_Study* _study ) + : PyInterp_LockRequest( _py_interp, 0, true ), // this request should be processed synchronously (sync == true) + myHelper( _helper ), + myStudy ( _study ) + {} + protected: + virtual void execute() + { + myHelper->internalClosedStudy( myStudy ); + } + private: + PyModuleHelper* myHelper; + SUIT_Study* myStudy; + }; + + // post request + PyInterp_Dispatcher::Get()->Exec( new StudyClosedReq( myInterp, this, study ) ); + + // disconnect preferences changing signal + disconnect( myModule->getApp(), SIGNAL( preferenceChanged( const QString&, const QString&, const QString& ) ), + this, SLOT( preferenceChanged( const QString&, const QString&, const QString& ) ) ); + + // disconnect the SUIT_Desktop signal windowActivated() + SUIT_Desktop* d = study->application()->desktop(); + disconnect( d, SIGNAL( windowActivated( SUIT_ViewWindow* ) ), + this, SLOT( activeViewChanged( SUIT_ViewWindow* ) ) ); + + // deactivate menus, toolbars, etc + if ( myXmlHandler ) myXmlHandler->activateMenus( false ); + + // hide menus / toolbars + myModule->setMenuShown( false ); + myModule->setToolShown( false ); +} + + /*! \brief Process module's preferences changing. @@ -2013,6 +2065,39 @@ void PyModuleHelper::internalDeactivate( SUIT_Study* study ) } } +/*! + \brief Internal closure: + + Performs the following actions: + - call Python module's closeStudy() method + + \param theStudy parent study object +*/ +void PyModuleHelper::internalClosedStudy( SUIT_Study* theStudy ) +{ + FuncMsg fmsg( "--- PyModuleHelper::internalClosedStudy()" ); + + // Get study Id + // get study Id + LightApp_Study* aStudy = dynamic_cast( theStudy ); + int aStudyId = aStudy ? aStudy->id() : 0; + + // check that Python subinterpreter is initialized and Python module is imported + if ( !myInterp || !myPyModule ) { + // Error! Python subinterpreter should be initialized and module should be imported first! + return; + } + // then call Python module's deactivate() method + if ( PyObject_HasAttrString( myPyModule , (char*)"closeStudy" ) ) { + PyObjWrapper res( PyObject_CallMethod( myPyModule, (char*)"closeStudy", (char*)"i", aStudyId ) ); + if( !res ) { + PyErr_Print(); + } + } +} + + + /*! \brief Preference changing callback function. \internal