Salome HOME
Fix a bug: problem with Python module initialization when there are light / non-light...
[modules/gui.git] / src / SALOME_PYQT / SALOME_PYQT_GUILight / SALOME_PYQT_ModuleLight.cxx
index 2fb54675d69b6b39394cb646090d13a09af67a7e..da7043dbd9a0e06e657a0bfbea63f61b999dcc4a 100644 (file)
@@ -35,6 +35,8 @@
 #include <Container_init_python.hxx>
 #endif
 
+#include <QCoreApplication>
+
 // Py_ssize_t for old Pythons
 // This code is as recommended by"
 // http://www.python.org/dev/peps/pep-0353/#conversion-guidelines
@@ -80,13 +82,14 @@ extern "C"
 {
   SALOME_PYQT_LIGHT_EXPORT CAM_Module* createModule() 
   {
-    static bool alreadyInitialized = false;
+    QCoreApplication* app = QCoreApplication::instance();
+    bool alreadyInitialized = app && app->property( "salome_pyqt_gui_light_initialized" ).toBool();
 
     // make initialization only once (see comment above) !
     if ( !alreadyInitialized ) {
       PyLockWrapper lck; // GIL acquisition
       INIT_FUNCTION();
-      alreadyInitialized = !alreadyInitialized;
+      if ( app ) app->setProperty( "salome_pyqt_gui_light_initialized", true );
     }
 
     return new SALOME_PYQT_ModuleLight();