]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
Problem is in import SalomePyQt agy/sigsegv_at_exit
authorAnthony Geay <anthony.geay@edf.fr>
Tue, 27 Apr 2021 19:06:29 +0000 (21:06 +0200)
committerAnthony Geay <anthony.geay@edf.fr>
Tue, 27 Apr 2021 19:06:29 +0000 (21:06 +0200)
src/SalomeApp/salome_pluginsmanager.py

index 8df655096da07874fc2dc3b20426f4ce0a12c12e..9ad3d5c4216552dc63d6d84d2bee375896ab888e 100644 (file)
@@ -82,18 +82,22 @@ context attributes:
 """
 
 import os,sys,traceback
-from qtsalome import *
 
 import salome
 
+sgPyQt = None
+
+def GetSgPyQt():
+  global sgPyQt
+  if sgPyQt is None:
+    import SalomePyQt
+    sgPyQt = SalomePyQt.SalomePyQt()
+  return sgPyQt
+
 SEP=":"
 if sys.platform == "win32":
   SEP = ";"
 
-# Get SALOME PyQt interface
-import SalomePyQt
-sgPyQt = SalomePyQt.SalomePyQt()
-
 # Get SALOME Swig interface
 import libSALOME_Swig
 sg = libSALOME_Swig.SALOMEGUI_Swig()
@@ -102,6 +106,8 @@ plugins={}
 current_plugins_manager=None
 
 def initialize(module,name,basemenuname,menuname):
+  # Get SALOME PyQt interface
+  sgPyQt = GetSgPyQt()
   if name not in plugins:
     if module:
       plugins[name]={}
@@ -122,6 +128,7 @@ class Context:
 def find_menu(smenu):
   lmenus=smenu.split("|")
   # Take first element from the list
+  sgPyQt = GetSgPyQt()
   main=lmenus.pop(0).strip()
   menu=sgPyQt.getPopupMenu(main)
   return findMenu(lmenus,menu)
@@ -146,6 +153,8 @@ logger=Logger("PluginsManager") #,color=GREEN)
 
 class PluginsManager:
     def __init__(self,module,name,basemenuname,menuname):
+        import qtsalome
+        sgPyQt = GetSgPyQt()
         self.name=name
         self.basemenuname=basemenuname
         self.menuname=menuname
@@ -201,10 +210,10 @@ class PluginsManager:
         self.basemenu = find_menu(self.basemenuname)
 
         if self.module:
-          self.menu=QMenu(self.menuname)
+          self.menu=qtsalome.QMenu(self.menuname)
           mid=sgPyQt.createMenu(self.menu.menuAction(),self.basemenuname)
         else:
-          self.menu=QMenu(self.menuname,self.basemenu)
+          self.menu=qtsalome.QMenu(self.menuname,self.basemenu)
           self.basemenu.addMenu(self.menu)
         self.toolbar=sgPyQt.createTool(self.menuname)
 
@@ -234,6 +243,7 @@ class PluginsManager:
         self.entries.append(name)
 
         def handler(obj=self,script=script):
+          sgPyQt = GetSgPyQt()
           try:
             script(Context(sgPyQt))
           except:
@@ -291,6 +301,7 @@ class PluginsManager:
     def updateMenu(self):
         """Update the Plugins menu"""
         self.menu.clear()
+        sgPyQt = GetSgPyQt()
         sgPyQt.clearTool(self.menuname)
         for entry in self.entries:
           names=entry.split("/")