]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
Multi-study removal: re-initialize study in the Python API after salome.salome_close... V9_2_0a2
authorvsr <vsr@opencascade.com>
Wed, 31 Oct 2018 09:45:05 +0000 (12:45 +0300)
committervsr <vsr@opencascade.com>
Wed, 31 Oct 2018 09:45:05 +0000 (12:45 +0300)
src/KERNEL_PY/__init__.py
src/KERNEL_PY/salome_study.py
src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx

index cb8a968f0cf0ff4222d312626913daafecc998f5..7c8d97bf1ec408b4af8114759ea438f4607c0a7e 100755 (executable)
@@ -214,6 +214,8 @@ def salome_close():
         pass
     salome_initial=True
     salome_iapp_close()
+    salome_study_close()
+    myStudy, myStudyName = None, None
     pass
 
 
index 5626aecdf8b13c3722364f03b1a79d6014d43d8e..0ebf612e35f1cf6e09756b4ebc114de08a8e8a0c 100755 (executable)
@@ -271,11 +271,11 @@ def FindFileInDataDir(filename):
     #--------------------------------------------------------------------------
 
 def openStudy(theStudyPath):
-    print("openStudy")
+    if verbose(): print("openStudy (begin)")
     global myStudy, myStudyName
     myStudy.Open(theStudyPath)
     myStudyName = myStudy._get_Name()
-    print(theStudyPath, myStudy._get_Name())
+    if verbose(): print("openStudy (end):", theStudyPath, myStudy._get_Name())
 
     #--------------------------------------------------------------------------
 
@@ -306,7 +306,13 @@ def salome_study_init(theStudyPath=None):
         if isinstance(theStudyPath, bytes):
             theStudyPath = str(theStudyPath, 'UTF8')
         openStudy(theStudyPath)
+    else:
+        myStudy.Init()
 
     myStudyName = myStudy._get_Name()
 
     return myStudy, myStudyName
+
+def salome_study_close():
+  global myStudy, myStudyName
+  myStudy, myStudyName = None, None
index 24f558ccb7190f1a820499bab3098a4010607c29..56718e43f4d409ad1026d3cd69f10e724c4e39ce 100644 (file)
@@ -109,7 +109,7 @@ namespace {
  *  Purpose  : SALOMEDSImpl_Study constructor
  */
 //============================================================================
-SALOMEDSImpl_Study::SALOMEDSImpl_Study()
+SALOMEDSImpl_Study::SALOMEDSImpl_Study() : _doc(NULL)
 {
   _appli = new DF_Application();
   _clipboard = _appli->NewDocument("SALOME_STUDY");
@@ -137,6 +137,9 @@ SALOMEDSImpl_Study::~SALOMEDSImpl_Study()
 //============================================================================
 void SALOMEDSImpl_Study::Init()
 {
+  if (_doc)
+    return; // noop: already initialized
+
   static int _id = 0;
   std::stringstream sstrm;
   sstrm << ++_id;