From: abd Date: Mon, 29 Jan 2007 13:42:06 +0000 (+0000) Subject: Improvement NPAL14675 X-Git-Tag: V3_2_5pre1~4 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=2f5dccf000dc3b8adf6d71717ce733e1d6313913;p=modules%2Fgui.git Improvement NPAL14675 Processing of status of activation for Python modules Improved method activateModule(...) Added member bool lastActivationStatus and private interface for it. --- 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 9e8cc8ca6..0a83e03d4 100644 --- a/src/SALOME_PYQT/SALOME_PYQT_GUI/SALOME_PYQT_Module.cxx +++ b/src/SALOME_PYQT/SALOME_PYQT_GUI/SALOME_PYQT_Module.cxx @@ -168,7 +168,8 @@ SALOME_PYQT_Module* SALOME_PYQT_Module::getInitModule() SALOME_PYQT_Module::SALOME_PYQT_Module() : SalomeApp_Module( __DEFAULT_NAME__ ), myModule( 0 ), - myXmlHandler ( 0 ) + myXmlHandler ( 0 ), + myLastActivateStatus( false ) { } @@ -275,6 +276,9 @@ bool SALOME_PYQT_Module::activateModule( SUIT_Study* theStudy ) // Posting the request PyInterp_Dispatcher::Get()->Exec( new ActivateReq( theStudy, this ) ); + if ( !lastActivationStatus() ) + return false; + // activate menus, toolbars, etc setMenuShown( true ); setToolShown( true ); @@ -366,6 +370,15 @@ bool SALOME_PYQT_Module::deactivateModule( SUIT_Study* theStudy ) return SalomeApp_Module::deactivateModule( theStudy ); } +/*! + * Returns the status of last trying of module activation. + * Before fisrt activation - status is false +*/ +bool SALOME_PYQT_Module::lastActivationStatus() const +{ + return myLastActivateStatus; +} + /*! Preferences changing (application) - called when preference is changed */ @@ -816,10 +829,18 @@ void SALOME_PYQT_Module::activate( SUIT_Study* theStudy ) // call Python module's activate() method (for the new modules) if(PyObject_HasAttrString(myModule , "activate")){ - PyObjWrapper res1( PyObject_CallMethod( myModule, "activate", "" ) ); - if( !res1 ) { - PyErr_Print(); - } + PyObject* res1 = PyObject_CallMethod( myModule, "activate", "" ); + if( !res1 || !PyBool_Check( res1 ) ) + { + PyErr_Print(); + //= true: for support of old modules + myLastActivateStatus = true; + } + else + { + //detect return status + myLastActivateStatus = PyObject_IsTrue( res1 ); + } } } 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 b8b9aeb90..65def75f6 100644 --- a/src/SALOME_PYQT/SALOME_PYQT_GUI/SALOME_PYQT_Module.h +++ b/src/SALOME_PYQT/SALOME_PYQT_GUI/SALOME_PYQT_Module.h @@ -74,6 +74,9 @@ private: QMap myWindowsMap; /* compatible view managers list */ QStringList myViewMgrList; + + /* status of last trying of module activation*/ + bool myLastActivateStatus; /****************************** * Construction/destruction @@ -200,6 +203,10 @@ private: void init ( CAM_Application* ); /* internal activation */ void activate ( SUIT_Study* ); + + /* getting status of last module activation */ + bool lastActivationStatus() const; + /* internal deactivation */ void deactivate ( SUIT_Study* ); /* customization */