From ab8d51ab0af41edf04df97c2128eb51866914432 Mon Sep 17 00:00:00 2001 From: san Date: Mon, 14 Nov 2011 16:09:45 +0000 Subject: [PATCH] PPGP issue #6: Can not get object name when Python module is inactive It is necessary to remember the current SALOME_PYQT_ModuleLigth instance temporarily in order to make it accessible from non-interactive functionality like save(), dumpStudy() when the module isnatnce might not be active. --- .../SALOME_PYQT_ModuleLight.cxx | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/SALOME_PYQT/SALOME_PYQT_GUILight/SALOME_PYQT_ModuleLight.cxx b/src/SALOME_PYQT/SALOME_PYQT_GUILight/SALOME_PYQT_ModuleLight.cxx index 965036feb..512e2bfec 100644 --- a/src/SALOME_PYQT/SALOME_PYQT_GUILight/SALOME_PYQT_ModuleLight.cxx +++ b/src/SALOME_PYQT/SALOME_PYQT_GUILight/SALOME_PYQT_ModuleLight.cxx @@ -2454,8 +2454,17 @@ void SALOME_PYQT_ModuleLight::saveEvent(QStringList& theListOfFiles) return; if ( PyObject_HasAttrString(myModule, (char*)"saveFiles") ) { + // temporary set myInitModule because saveEvent() method + // might be called by the framework when this module is inactive, + // but still it should be possible to access this module's data + // from Python + myInitModule = this; + PyObjWrapper res( PyObject_CallMethod( myModule, (char*)"saveFiles", (char*)"s", (*it).toLatin1().constData())); + + myInitModule = 0; + if( !res ) { PyErr_Print(); } @@ -2524,8 +2533,17 @@ void SALOME_PYQT_ModuleLight::dumpEvent(QStringList& theListOfFiles) return; if ( PyObject_HasAttrString(myModule, (char*)"dumpStudy") ) { + // temporary set myInitModule because dumpEvent() method + // might be called by the framework when this module is inactive, + // but still it should be possible to access this module's data + // from Python + myInitModule = this; + PyObjWrapper res( PyObject_CallMethod( myModule, (char*)"dumpStudy", (char*)"s", (*it).toLatin1().constData())); + + myInitModule = 0; + if( !res ) { PyErr_Print(); } -- 2.39.2