From: jfa Date: Tue, 15 Aug 2006 09:47:29 +0000 (+0000) Subject: PAL12755: EDF: SALOME frozen with Load Script and a Python Module. Additional fix. X-Git-Tag: For_OCT_611~4 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=a1cb7e889cb1264cfd0a8cb91d34b00a8c8cda78;p=modules%2Fgui.git PAL12755: EDF: SALOME frozen with Load Script and a Python Module. Additional fix. --- diff --git a/src/SALOME_PY/SalomePy.cxx b/src/SALOME_PY/SalomePy.cxx index eb9a20756..30f556718 100755 --- a/src/SALOME_PY/SalomePy.cxx +++ b/src/SALOME_PY/SalomePy.cxx @@ -116,7 +116,12 @@ public: }; extern "C" PyObject *libSalomePy_getRenderer(PyObject *self, PyObject *args) { - return ProcessEvent( new TGetRendererEvent() ); + //return ProcessEvent( new TGetRendererEvent() ); + PyObject * aResult; + Py_BEGIN_ALLOW_THREADS // PAL12755 + aResult = ProcessEvent( new TGetRendererEvent() ); + Py_END_ALLOW_THREADS // PAL12755 + return aResult; } /*! @@ -137,7 +142,12 @@ public: }; extern "C" PyObject *libSalomePy_getRenderWindow(PyObject *self, PyObject *args) { - return ProcessEvent( new TGetRenderWindowEvent() ); + //return ProcessEvent( new TGetRenderWindowEvent() ); + PyObject * aResult; + Py_BEGIN_ALLOW_THREADS // PAL12755 + aResult = ProcessEvent( new TGetRenderWindowEvent() ); + Py_END_ALLOW_THREADS // PAL12755 + return aResult; } /*! @@ -158,7 +168,12 @@ public: }; extern "C" PyObject *libSalomePy_getRenderWindowInteractor(PyObject *self, PyObject *args) { - return ProcessEvent( new TGetRenderWindowInteractorEvent() ); + //return ProcessEvent( new TGetRenderWindowInteractorEvent() ); + PyObject * aResult; + Py_BEGIN_ALLOW_THREADS // PAL12755 + aResult = ProcessEvent( new TGetRenderWindowInteractorEvent() ); + Py_END_ALLOW_THREADS // PAL12755 + return aResult; } /*! diff --git a/src/SALOME_PYQT/SalomePyQt/SalomePyQt_v4.sip b/src/SALOME_PYQT/SalomePyQt/SalomePyQt_v4.sip index 3d0196f88..a1a1c046a 100644 --- a/src/SALOME_PYQT/SalomePyQt/SalomePyQt_v4.sip +++ b/src/SALOME_PYQT/SalomePyQt/SalomePyQt_v4.sip @@ -18,9 +18,9 @@ class SALOME_Selection : QObject %End public: - void Clear(); - void ClearIObjects(); - void ClearFilters(); + void Clear() /ReleaseGIL/ ; + void ClearIObjects() /ReleaseGIL/ ; + void ClearFilters() /ReleaseGIL/ ; private: SALOME_Selection( QObject* /TransferThis/ ); @@ -63,71 +63,71 @@ class SalomePyQt %End public: - static QWidget* getDesktop(); - static QWidget* getMainFrame(); - static QMenuBar* getMainMenuBar(); - static QPopupMenu* getPopupMenu( const MenuName ); - static SALOME_Selection* getSelection() /Factory/; - static int getStudyId(); - static void putInfo( const QString&, const int = 0 ); - static const QString getActiveComponent(); - static void updateObjBrowser( const int = 0, bool = true ); + static QWidget* getDesktop() /ReleaseGIL/ ; + static QWidget* getMainFrame() /ReleaseGIL/ ; + static QMenuBar* getMainMenuBar() /ReleaseGIL/ ; + static QPopupMenu* getPopupMenu( const MenuName ) /ReleaseGIL/ ; + static SALOME_Selection* getSelection() /Factory,ReleaseGIL/ ; + static int getStudyId() /ReleaseGIL/ ; + static void putInfo( const QString&, const int = 0 ) /ReleaseGIL/ ; + static const QString getActiveComponent() /ReleaseGIL/ ; + static void updateObjBrowser( const int = 0, bool = true ) /ReleaseGIL/ ; static QString getFileName ( QWidget*, const QString&, const QStringList&, const QString&, bool ) /ReleaseGIL/ ; static QStringList getOpenFileNames ( QWidget*, const QString&, const QStringList&, const QString& ) /ReleaseGIL/ ; static QString getExistingDirectory( QWidget*, const QString&, const QString& ) /ReleaseGIL/ ; - static void helpContext( const QString&, const QString& ); + static void helpContext( const QString&, const QString& ) /ReleaseGIL/ ; - static bool dumpView( const QString& ); + static bool dumpView( const QString& ) /ReleaseGIL/ ; - static int defaultMenuGroup(); + static int defaultMenuGroup() /ReleaseGIL/ ; - static int createTool( const QString& ); - static int createTool( const int, const int, const int = -1 ); - static int createTool( const int, const QString&, const int = -1 ); - static int createTool( QtxAction*, const int, const int = -1, const int = -1 ); - static int createTool( QtxAction*, const QString&, const int = -1, const int = -1 ); + static int createTool( const QString& ) /ReleaseGIL/ ; + static int createTool( const int, const int, const int = -1 ) /ReleaseGIL/ ; + static int createTool( const int, const QString&, const int = -1 ) /ReleaseGIL/ ; + static int createTool( QtxAction*, const int, const int = -1, const int = -1 ) /ReleaseGIL/ ; + static int createTool( QtxAction*, const QString&, const int = -1, const int = -1 ) /ReleaseGIL/ ; static int createMenu( const QString&, const int, - const int = -1, const int = -1, const int = -1 ); + const int = -1, const int = -1, const int = -1 ) /ReleaseGIL/ ; static int createMenu( const QString&, const QString&, - const int = -1, const int = -1, const int = -1 ); + const int = -1, const int = -1, const int = -1 ) /ReleaseGIL/ ; static int createMenu( const int, const int, - const int = -1, const int = -1 ); + const int = -1, const int = -1 ) /ReleaseGIL/ ; static int createMenu( const int, const QString&, - const int = -1, const int = -1 ); + const int = -1, const int = -1 ) /ReleaseGIL/ ; static int createMenu( QtxAction*, const int, const int = -1, - const int = -1, const int = -1 ); + const int = -1, const int = -1 ) /ReleaseGIL/ ; static int createMenu( QtxAction*, const QString&, const int = -1, - const int = -1, const int = -1 ); - static QtxAction* createSeparator(); + const int = -1, const int = -1 ) /ReleaseGIL/ ; + static QtxAction* createSeparator() /ReleaseGIL/ ; static QtxAction* createAction( const int, const QString&, const QString& = QString::null, const QString& = QString::null, - const QString& = QString::null, const int = 0, const bool = false ); + const QString& = QString::null, const int = 0, const bool = false ) /ReleaseGIL/ ; - static QtxAction* action( const int ); - static int actionId( const QtxAction* ); + static QtxAction* action( const int ) /ReleaseGIL/ ; + static int actionId( const QtxAction* ) /ReleaseGIL/ ; static bool clearMenu( const int = 0, const int = 0, - const bool = true ); - - static void addSetting ( const QString&, const QString&, const double ); - static void addSetting ( const QString&, const QString&, const int /Constrained/ ); - static void addSetting ( const QString&, const QString&, const QString& ); - static void addSetting ( const QString&, const QString&, const QColor& ); - static int integerSetting( const QString&, const QString&, const int = 0 ); - static double doubleSetting ( const QString&, const QString&, const int = 0 ); - static bool boolSetting ( const QString&, const QString&, const bool = false ); - static QString stringSetting ( const QString&, const QString&, const QString& = QString("") ); - static QColor colorSetting ( const QString&, const QString&, const QColor& = QColor() ); - static void removeSetting ( const QString&, const QString& ); + const bool = true ) /ReleaseGIL/ ; + + static void addSetting ( const QString&, const QString&, const double ) /ReleaseGIL/ ; + static void addSetting ( const QString&, const QString&, const int /Constrained/ ) /ReleaseGIL/ ; + static void addSetting ( const QString&, const QString&, const QString& ) /ReleaseGIL/ ; + static void addSetting ( const QString&, const QString&, const QColor& ) /ReleaseGIL/ ; + static int integerSetting( const QString&, const QString&, const int = 0 ) /ReleaseGIL/ ; + static double doubleSetting ( const QString&, const QString&, const int = 0 ) /ReleaseGIL/ ; + static bool boolSetting ( const QString&, const QString&, const bool = false ) /ReleaseGIL/ ; + static QString stringSetting ( const QString&, const QString&, const QString& = QString("") ) /ReleaseGIL/ ; + static QColor colorSetting ( const QString&, const QString&, const QColor& = QColor() ) /ReleaseGIL/ ; + static void removeSetting ( const QString&, const QString& ) /ReleaseGIL/ ; // obsolete - static void addStringSetting( const QString&, const QString&, bool = true ); - static void addIntSetting ( const QString&, const int, bool = true ); - static void addDoubleSetting( const QString&, const double, bool = true ); - static void removeSettings ( const QString& ); - static QString getSetting ( const QString& ); + static void addStringSetting( const QString&, const QString&, bool = true ) /ReleaseGIL/ ; + static void addIntSetting ( const QString&, const int, bool = true ) /ReleaseGIL/ ; + static void addDoubleSetting( const QString&, const double, bool = true ) /ReleaseGIL/ ; + static void removeSettings ( const QString& ) /ReleaseGIL/ ; + static QString getSetting ( const QString& ) /ReleaseGIL/ ; }; diff --git a/src/SALOME_SWIG/SALOMEGUI_Swig.i b/src/SALOME_SWIG/SALOMEGUI_Swig.i index e960e05bf..01eda8ec4 100644 --- a/src/SALOME_SWIG/SALOMEGUI_Swig.i +++ b/src/SALOME_SWIG/SALOMEGUI_Swig.i @@ -34,9 +34,25 @@ /* Exception handler for all functions */ %exception { - Py_BEGIN_ALLOW_THREADS - $action - Py_END_ALLOW_THREADS + class PyAllowThreadsGuard { + public: + // Py_BEGIN_ALLOW_THREADS + PyAllowThreadsGuard() { _save = PyEval_SaveThread(); } + // Py_END_ALLOW_THREADS + ~PyAllowThreadsGuard() { PyEval_RestoreThread(_save); } + private: + PyThreadState *_save; + }; + + PyAllowThreadsGuard guard; + + try { + $action + } + catch(...) { + PyErr_SetString(PyExc_RuntimeError,"Unknown exception caught"); + return NULL; + } } class SALOMEGUI_Swig