From: mpa Date: Fri, 16 Dec 2016 06:48:15 +0000 (+0300) Subject: fix problem with opening study by salome.openStudy(hdf) method X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=22fef16356c8eb8e9dd1542ac49669f373786db3;p=modules%2Fyacs.git fix problem with opening study by salome.openStudy(hdf) method --- diff --git a/src/KERNEL_PY/PyInterp.py b/src/KERNEL_PY/PyInterp.py index 3c0787e4c..c14efb152 100755 --- a/src/KERNEL_PY/PyInterp.py +++ b/src/KERNEL_PY/PyInterp.py @@ -95,5 +95,5 @@ myStudyName = sg.getStudyName() print myStudyName # get Study reference -obj = naming_service.Resolve('Study') +obj = naming_service.Resolve('/Study') myStudy = obj._narrow(SALOMEDS.Study) diff --git a/src/KERNEL_PY/batchmode_salome.py b/src/KERNEL_PY/batchmode_salome.py index 8d60ebadf..4e52b1fe4 100755 --- a/src/KERNEL_PY/batchmode_salome.py +++ b/src/KERNEL_PY/batchmode_salome.py @@ -276,7 +276,7 @@ step = 0 sleeping_time = 0.01 sleeping_time_max = 1.0 while 1: - obj = naming_service.Resolve('Study') + obj = naming_service.Resolve('/Study') if obj is not None:break step = step + 1 if step > 100: break diff --git a/src/KERNEL_PY/salome_study.py b/src/KERNEL_PY/salome_study.py index f249057f9..efd41940b 100755 --- a/src/KERNEL_PY/salome_study.py +++ b/src/KERNEL_PY/salome_study.py @@ -52,7 +52,7 @@ def DumpComponent(SO, Builder,offset): if find: a=a+":"+RefSO.GetID() print a - DumpComponent(Study, CSO, Builder,offset+2) + DumpComponent(CSO, Builder,offset+2) it.Next() #-------------------------------------------------------------------------- @@ -272,8 +272,9 @@ def FindFileInDataDir(filename): def openStudy(theStudyPath): print "openStudy" - global myStudy + global myStudy, myStudyName myStudy.Open(theStudyPath) + myStudyName = myStudy._get_Name() print theStudyPath, myStudy._get_Name() #-------------------------------------------------------------------------- @@ -295,7 +296,7 @@ def salome_study_init(theStudyPath=None): # get Study reference if verbose(): print "looking for study..." - obj = naming_service.Resolve('Study') + obj = naming_service.Resolve('/Study') myStudy = obj._narrow(SALOMEDS.Study) if verbose(): print "Study found" pass diff --git a/src/SALOMEDS/SALOMEDS_Client.cxx b/src/SALOMEDS/SALOMEDS_Client.cxx index fd365b910..db409bbf5 100644 --- a/src/SALOMEDS/SALOMEDS_Client.cxx +++ b/src/SALOMEDS/SALOMEDS_Client.cxx @@ -270,7 +270,7 @@ int main(int argc, char** argv) SALOME_NamingService * salomens = new SALOME_NamingService(orb); MESSAGE("Find Study "); - CORBA::Object_ptr obj2 = salomens->Resolve("Study"); + CORBA::Object_ptr obj2 = salomens->Resolve("/Study"); SALOMEDS::Study_var myStudy = SALOMEDS::Study::_narrow(obj2); // Obtain a POAManager, and tell the POA to start accepting diff --git a/src/SALOMEDS/SALOMEDS_Server.cxx b/src/SALOMEDS/SALOMEDS_Server.cxx index a1e9a1af1..21db9a8c0 100644 --- a/src/SALOMEDS/SALOMEDS_Server.cxx +++ b/src/SALOMEDS/SALOMEDS_Server.cxx @@ -59,7 +59,7 @@ int main(int argc, char** argv) #else CORBA::ORB_var orb = CORBA::ORB_init( argc, argv, "omniORB3" ); #endif - SALOME_NamingService NS; + SALOME_NamingService* NS; // Obtain a reference to the root POA. long TIMESleep = 500000000; int NumberOfTries = 40; @@ -109,8 +109,8 @@ int main(int argc, char** argv) if(EnvL==1) { CORBA::ORB_var orb1 = CORBA::ORB_init(argc,argv) ; - NS = *SINGLETON_::Instance() ; - NS.init_orb( orb1 ) ; + NS = SINGLETON_::Instance() ; + NS->init_orb( orb1 ) ; for(int j=1; j<=NumberOfTries; j++) { if (j!=1) @@ -161,7 +161,12 @@ int main(int argc, char** argv) // ready to accept requests. PortableServer::ObjectId_var myStudy_iid = poa->activate_object(myStudy_i); SALOMEDS::Study_var Study = myStudy_i->_this(); - NS.Register(Study.in(), "/Study"); + if (!NS) + { + NS = SINGLETON_::Instance(); + NS->init_orb( orb ); + } + NS->Register(Study.in(), "/Study"); // Assign the value of the IOR in the study->root CORBA::String_var IORStudy = orb->object_to_string(Study); diff --git a/src/SALOMEDS/SALOMEDS_Study.cxx b/src/SALOMEDS/SALOMEDS_Study.cxx index a8bcfbd84..8b14dd003 100644 --- a/src/SALOMEDS/SALOMEDS_Study.cxx +++ b/src/SALOMEDS/SALOMEDS_Study.cxx @@ -70,7 +70,7 @@ SALOMEDS_Study::SALOMEDS_Study(SALOMEDSImpl_Study* theStudy) _isLocal = true; _local_impl = theStudy; _corba_impl = SALOMEDS::Study::_nil(); - Init(); + InitORB(); } SALOMEDS_Study::SALOMEDS_Study(SALOMEDS::Study_ptr theStudy) @@ -100,7 +100,7 @@ SALOMEDS_Study::~SALOMEDS_Study() void SALOMEDS_Study::InitORB() { - ORB_INIT &init = *SINGLETON_::Instance() ; + ORB_INIT &init = *SINGLETON_::Instance(); ASSERT(SINGLETON_::IsAlreadyExisting()); _orb = init(0 , 0 ) ; } diff --git a/src/SALOMEDS/SALOMEDS_Study_i.cxx b/src/SALOMEDS/SALOMEDS_Study_i.cxx index 08fc42dcb..23cc0c031 100644 --- a/src/SALOMEDS/SALOMEDS_Study_i.cxx +++ b/src/SALOMEDS/SALOMEDS_Study_i.cxx @@ -379,6 +379,9 @@ void SALOMEDS_Study_i::Clear() bool SALOMEDS_Study_i::Open(const char* aUrl) throw(SALOME::SALOME_Exception) { + if (!_closed) + Clear(); + Init(); SALOMEDS::Locker lock; Unexpect aCatch(SalomeException); diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx index dd39cc41a..6e1e77792 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx @@ -142,7 +142,7 @@ void SALOMEDSImpl_Study::Init() sstrm << ++_id; _name = "Study" + std::string(sstrm.str()); _doc = _appli->NewDocument("SALOME_STUDY"); - _Saved = false ; + _Saved = false; _URL = ""; _autoFill = false; _errorCode = ""; @@ -175,6 +175,7 @@ void SALOMEDSImpl_Study::Clear() delete _builder; delete _cb; delete _useCaseBuilder; + URL(""); _appli->Close(_doc); _doc = NULL; _mapOfSO.clear(); @@ -188,8 +189,6 @@ void SALOMEDSImpl_Study::Clear() //============================================================================ bool SALOMEDSImpl_Study::Open(const std::string& aUrl) { - Clear(); - Init(); // Set "C" locale temporarily to avoid possible localization problems Kernel_Utils::Localizer loc; diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_StudyBuilder.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_StudyBuilder.cxx index f3e530112..3a6853693 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_StudyBuilder.cxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_StudyBuilder.cxx @@ -52,11 +52,11 @@ static void Translate_persistentID_to_IOR(DF_Label& Lab, SALOMEDSImpl_Driver* dr //============================================================================ SALOMEDSImpl_StudyBuilder::SALOMEDSImpl_StudyBuilder(const SALOMEDSImpl_Study* theOwner) { - _errorCode = ""; + _errorCode = ""; _callbackOnAdd=NULL; _callbackOnRemove = NULL; - _study = (SALOMEDSImpl_Study*)theOwner; - _doc = _study->GetDocument(); + _study = (SALOMEDSImpl_Study*)theOwner; + _doc = _study->GetDocument(); } //============================================================================