From 0da95e93aead63360b20145e303f1072e99817a5 Mon Sep 17 00:00:00 2001 From: vsr Date: Mon, 19 Oct 2009 08:10:58 +0000 Subject: [PATCH] Issue 0020536: EDF 1136 GUI: SIGSEGV for Python module if import process of GUI component raises an exception --- .../SALOME_PYQT_GUI/SALOME_PYQT_Module.cxx | 12 ++++++++++-- src/SALOME_PYQT/SALOME_PYQT_GUI/SALOME_PYQT_Module.h | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) 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 35c178b97..d3aa08926 100644 --- a/src/SALOME_PYQT/SALOME_PYQT_GUI/SALOME_PYQT_Module.cxx +++ b/src/SALOME_PYQT/SALOME_PYQT_GUI/SALOME_PYQT_Module.cxx @@ -195,6 +195,10 @@ SALOME_PYQT_Module::~SALOME_PYQT_Module() { if ( myXmlHandler ) delete myXmlHandler; + if ( myInterp && myModule ) { + PyLockWrapper aLock = myInterp->GetLockWrapper(); + Py_XDECREF(myModule); + } } /*! @@ -834,13 +838,17 @@ void SALOME_PYQT_Module::activate( SUIT_Study* theStudy ) // initialize Python subinterpreter (on per study) and put it in variable initInterp( aStudyId ); - if ( !myInterp ) + if ( !myInterp ) { + myLastActivateStatus = false; return; // Error + } // import Python GUI module importModule(); - if ( !myModule ) + if ( !myModule ) { + myLastActivateStatus = false; return; // Error + } // get python lock PyLockWrapper aLock = myInterp->GetLockWrapper(); 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 beeb04b7b..b51ec51d7 100644 --- a/src/SALOME_PYQT/SALOME_PYQT_GUI/SALOME_PYQT_Module.h +++ b/src/SALOME_PYQT/SALOME_PYQT_GUI/SALOME_PYQT_Module.h @@ -54,7 +54,7 @@ private: /* current Python subinterpreter */ SALOME_PYQT_PyInterp* myInterp; /* Python GUI module loaded */ - PyObjWrapper myModule; + PyObject* myModule; /* Python GUI being initialized (not zero only during the initialization)*/ static SALOME_PYQT_Module* myInitModule; -- 2.39.2