From: Paul RASCLE Date: Sat, 12 Apr 2014 15:17:09 +0000 (+0200) Subject: forbid several simultaneously active studies in the same session, in study creation... X-Git-Tag: V7_4_0b1~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=45960eff1a05ae1b60bfb29f4c999424827437d8;p=modules%2Fkernel.git forbid several simultaneously active studies in the same session, in study creation or opening --- diff --git a/idl/SALOMEDS.idl b/idl/SALOMEDS.idl index d911ea1ad..2fcb127bc 100644 --- a/idl/SALOMEDS.idl +++ b/idl/SALOMEDS.idl @@ -929,7 +929,7 @@ Searches for a definite %SObject with a definite GUID and returns True if it fin See \ref example17 for an example of this method usage in batchmode of %SALOME application. */ - Study NewStudy(in string study_name); + Study NewStudy(in string study_name) raises (SALOME::SALOME_Exception); /*! \brief Open a study diff --git a/src/SALOMEDS/SALOMEDS_StudyManager_i.cxx b/src/SALOMEDS/SALOMEDS_StudyManager_i.cxx index 64af49fbd..ae55ffd06 100644 --- a/src/SALOMEDS/SALOMEDS_StudyManager_i.cxx +++ b/src/SALOMEDS/SALOMEDS_StudyManager_i.cxx @@ -112,9 +112,21 @@ void SALOMEDS_StudyManager_i::register_name(const char * name) */ //============================================================================ SALOMEDS::Study_ptr SALOMEDS_StudyManager_i::NewStudy(const char* study_name) + throw(SALOME::SALOME_Exception) { SALOMEDS::Locker lock; +#ifndef ALLOW_MULTI_STUDIES + std::vector anOpened = _impl->GetOpenStudies(); + int aLength = anOpened.size(); + + if(aLength) + { + MESSAGE("There is already an active study in this session. Launch a new session, or close the study"); + THROW_SALOME_CORBA_EXCEPTION("Problem on New Study.\nThere is already an active study in this session.\nLaunch a new session, or close the study", SALOME::BAD_PARAM) + } +#endif // !ALLOW_MULTI_STUDIES + SALOMEDSImpl_Study* aStudyImpl = _impl->NewStudy(study_name); if(!aStudyImpl) { MESSAGE("NewStudy : Error : " << _impl->GetErrorCode()); @@ -157,6 +169,17 @@ SALOMEDS::Study_ptr SALOMEDS_StudyManager_i::Open(const char* aUrl) Unexpect aCatch(SalomeException); MESSAGE("Begin of SALOMEDS_StudyManager_i::Open"); + #ifndef ALLOW_MULTI_STUDIES + std::vector anOpened = _impl->GetOpenStudies(); + int aLength = anOpened.size(); + + if(aLength) + { + MESSAGE("There is already an active study in this session. Launch a new session, or close the study."); + THROW_SALOME_CORBA_EXCEPTION("Problem on Open Study.\nThere is already an active study in this session.\nLaunch a new session, or close the study.", SALOME::BAD_PARAM) + } +#endif // ;ALLOW_MULTI_STUDIES + SALOMEDSImpl_Study* aStudyImpl = _impl->Open(std::string(aUrl)); if ( !aStudyImpl ) diff --git a/src/SALOMEDS/SALOMEDS_StudyManager_i.hxx b/src/SALOMEDS/SALOMEDS_StudyManager_i.hxx index 0e0748c50..c323ef747 100644 --- a/src/SALOMEDS/SALOMEDS_StudyManager_i.hxx +++ b/src/SALOMEDS/SALOMEDS_StudyManager_i.hxx @@ -82,7 +82,7 @@ public: \param char* arguments, the new study name \return Study_ptr arguments */ - virtual SALOMEDS::Study_ptr NewStudy(const char* study_name); + virtual SALOMEDS::Study_ptr NewStudy(const char* study_name) throw (SALOME::SALOME_Exception); //! method to Open a Study from it's persistent reference /*!