From: vsr Date: Wed, 31 Oct 2018 09:45:05 +0000 (+0300) Subject: Multi-study removal: re-initialize study in the Python API after salome.salome_close... X-Git-Tag: V9_2_0a2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=d8aec81625804bf9e77bb87ce949f09b3eb85ccc;p=modules%2Fkernel.git Multi-study removal: re-initialize study in the Python API after salome.salome_close() -> salome.salome_init() --- diff --git a/src/KERNEL_PY/__init__.py b/src/KERNEL_PY/__init__.py index cb8a968f0..7c8d97bf1 100755 --- a/src/KERNEL_PY/__init__.py +++ b/src/KERNEL_PY/__init__.py @@ -214,6 +214,8 @@ def salome_close(): pass salome_initial=True salome_iapp_close() + salome_study_close() + myStudy, myStudyName = None, None pass diff --git a/src/KERNEL_PY/salome_study.py b/src/KERNEL_PY/salome_study.py index 5626aecdf..0ebf612e3 100755 --- a/src/KERNEL_PY/salome_study.py +++ b/src/KERNEL_PY/salome_study.py @@ -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 diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx index 24f558ccb..56718e43f 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx @@ -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;