From 83bf294add2f4e73bf6072f6a739e3601b05b5fb Mon Sep 17 00:00:00 2001 From: imn Date: Wed, 2 Nov 2016 17:14:17 +0300 Subject: [PATCH] Fix problem with waiting SALOMEDS_Server: - delete RegisterGenObj object --- bin/runSalome.py | 2 +- src/SALOMEDS/SALOMEDS.cxx | 7 +- src/SALOMEDS/SALOMEDS_Server.cxx | 14 ++-- src/SALOMEDS/SALOMEDS_Study_i.cxx | 64 ------------------- src/SALOMEDS/SALOMEDS_Study_i.hxx | 1 - src/SALOMEDS/SALOME_DriverPy.py | 2 +- .../SALOMEDSImpl_AttributeIOR.cxx | 12 ---- src/SALOMEDSImpl/SALOMEDSImpl_Callback.hxx | 2 - src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx | 44 ------------- src/SALOMEDSImpl/SALOMEDSImpl_Study.hxx | 5 -- .../SALOMEDSImpl_StudyBuilder.cxx | 5 +- 11 files changed, 14 insertions(+), 144 deletions(-) diff --git a/bin/runSalome.py b/bin/runSalome.py index b547c3703..75a060437 100755 --- a/bin/runSalome.py +++ b/bin/runSalome.py @@ -687,7 +687,7 @@ def useSalome(args, modules_list, modules_root_dir): toopen = args['study_hdf'] if toopen: import salome - salome.salome_init(toopen) + salome.salome_init() if args.has_key('pyscript'): toimport = args['pyscript'] from salomeContextUtils import formatScriptsAndArgs diff --git a/src/SALOMEDS/SALOMEDS.cxx b/src/SALOMEDS/SALOMEDS.cxx index 6199d4fed..9d8112092 100644 --- a/src/SALOMEDS/SALOMEDS.cxx +++ b/src/SALOMEDS/SALOMEDS.cxx @@ -117,14 +117,9 @@ extern "C" PortableServer::ObjectId_var aStudy_iid = root_poa->activate_object(aStudy_i); aStudy = aStudy_i->_this(); namingService.Register(aStudy.in(), "/Study"); - - // Assign the value of the IOR in the study->root - CORBA::String_var IORStudy = orb->object_to_string(aStudy); - aStudy_i->GetImpl()->SetTransientReference((char*)IORStudy.in()); } - SALOMEDS_Study* study = new SALOMEDS_Study(aStudy_i->GetImpl()); aStudy_i->_remove_ref(); - return study; + return NULL; } SALOMEDS_EXPORT diff --git a/src/SALOMEDS/SALOMEDS_Server.cxx b/src/SALOMEDS/SALOMEDS_Server.cxx index a1e9a1af1..a9893daa2 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,13 @@ 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_i.cxx b/src/SALOMEDS/SALOMEDS_Study_i.cxx index 5c1337f18..d0eef1dd5 100644 --- a/src/SALOMEDS/SALOMEDS_Study_i.cxx +++ b/src/SALOMEDS/SALOMEDS_Study_i.cxx @@ -179,50 +179,6 @@ namespace SALOMEDS CORBA::ORB_var _orb; }; - class GenObjRegister: public SALOMEDSImpl_AbstractCallback - { - public: - GenObjRegister(CORBA::ORB_ptr orb) - { - _orb = CORBA::ORB::_duplicate(orb); - } - virtual void RegisterGenObj (const std::string& theIOR) - { - try - { - CORBA::Object_var obj = _orb->string_to_object(theIOR.c_str()); - if ( obj->_non_existent() ) return; - SALOME::GenericObj_var gobj = SALOME::GenericObj::_narrow(obj); - if(! CORBA::is_nil(gobj) ) - { - gobj->Register(); - } - } - catch(const CORBA::Exception& e) - { - } - } - virtual void UnRegisterGenObj(const std::string& theIOR) - { - try - { - CORBA::Object_var obj = _orb->string_to_object(theIOR.c_str()); - if ( obj->_non_existent() ) return; - SALOME::GenericObj_var gobj = SALOME::GenericObj::_narrow(obj); - if(! CORBA::is_nil(gobj) ) - { - gobj->UnRegister(); - } - } - catch(const CORBA::Exception& e) - { - } - } - - private: - CORBA::ORB_var _orb; - }; - } // namespace SALOMEDS //============================================================================ @@ -260,11 +216,9 @@ void SALOMEDS_Study_i::Init() { _builder = new SALOMEDS_StudyBuilder_i(_impl->NewBuilder(), _orb); _notifier = new SALOMEDS::Notifier(_orb); - _genObjRegister = new SALOMEDS::GenObjRegister(_orb); _closed = false; _impl->setNotifier(_notifier); - _impl->setGenObjRegister( _genObjRegister ); // Notify GUI that study was created SALOME_NamingService *aNamingService = KERNEL::getNamingService(); @@ -296,7 +250,6 @@ void SALOMEDS_Study_i::Clear() _impl->Clear(); _impl->setNotifier(0); delete _notifier; - delete _genObjRegister; SALOMEDS::Locker lock; @@ -1072,23 +1025,6 @@ void SALOMEDS_Study_i::UpdateIORLabelMap(const char* anIOR, const char* anEntry) _impl->UpdateIORLabelMap(std::string((char*)anIOR), std::string((char*)anEntry)); } -SALOMEDS::Study_ptr SALOMEDS_Study_i::GetStudy(const DF_Label& theLabel, CORBA::ORB_ptr orb) -{ - SALOMEDS::Locker lock; - - SALOMEDSImpl_AttributeIOR* Att = NULL; - if ((Att=(SALOMEDSImpl_AttributeIOR*)theLabel.Root().FindAttribute(SALOMEDSImpl_AttributeIOR::GetID()))){ - char* IOR = CORBA::string_dup(Att->Value().c_str()); - CORBA::Object_var obj = orb->string_to_object(IOR); - SALOMEDS::Study_ptr aStudy = SALOMEDS::Study::_narrow(obj) ; - ASSERT(!CORBA::is_nil(aStudy)); - return SALOMEDS::Study::_duplicate(aStudy); - } else { - MESSAGE("GetStudy: Problem to get study"); - } - return SALOMEDS::Study::_nil(); -} - void SALOMEDS_Study_i::IORUpdated(SALOMEDSImpl_AttributeIOR* theAttribute) { SALOMEDS::Locker lock; diff --git a/src/SALOMEDS/SALOMEDS_Study_i.hxx b/src/SALOMEDS/SALOMEDS_Study_i.hxx index 20b3bd6d2..bfa702ddd 100644 --- a/src/SALOMEDS/SALOMEDS_Study_i.hxx +++ b/src/SALOMEDS/SALOMEDS_Study_i.hxx @@ -54,7 +54,6 @@ private: SALOMEDSImpl_Study* _impl; SALOMEDS_StudyBuilder_i* _builder; SALOMEDSImpl_AbstractCallback* _notifier; - SALOMEDSImpl_AbstractCallback* _genObjRegister; SALOMEDS_DriverFactory_i* _factory; bool _closed; diff --git a/src/SALOMEDS/SALOME_DriverPy.py b/src/SALOMEDS/SALOME_DriverPy.py index c2e4cf58a..9757721b6 100644 --- a/src/SALOMEDS/SALOME_DriverPy.py +++ b/src/SALOMEDS/SALOME_DriverPy.py @@ -70,7 +70,7 @@ class SALOME_DriverPy_i(SALOMEDS__POA.Driver): def CanPublishInStudy(self, theIOR): return 1 - def PublishInStudy(self, theStudy, theSObject, theObject, theName): + def PublishInStudy(self, theSObject, theObject, theName): return None def CanCopy(self, theObject): diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeIOR.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeIOR.cxx index f5c8ec764..8983f3d94 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeIOR.cxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeIOR.cxx @@ -65,19 +65,8 @@ void SALOMEDSImpl_AttributeIOR::SetValue(const std::string& theValue) CheckLocked(); Backup(); - //remove IOR entry in study - if(theValue != myString) - { - SALOMEDSImpl_Study* study=SALOMEDSImpl_Study::GetStudy(Label()); - study->RegisterGenObj(theValue, Label()); - study->UnRegisterGenObj(myString, Label()); - study->DeleteIORLabelMapItem(myString); - } myString = theValue; - - //add IOR entry in study - SALOMEDSImpl_Study::IORUpdated(this); //Reason = 5 means that IOR attribute updated //Used in the gui module to detect that IOR attribure was assigned to the object @@ -104,7 +93,6 @@ SALOMEDSImpl_AttributeIOR::SALOMEDSImpl_AttributeIOR() SALOMEDSImpl_AttributeIOR::~SALOMEDSImpl_AttributeIOR() { - SALOMEDSImpl_Study::UnRegisterGenObj(myString, Label()); } //======================================================================= diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_Callback.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_Callback.hxx index 8c5ae3c64..0b935d0c2 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_Callback.hxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_Callback.hxx @@ -61,7 +61,5 @@ public: virtual bool removeSO_Notification(const SALOMEDSImpl_SObject& theSObject){return false;}; virtual bool modifySO_Notification(const SALOMEDSImpl_SObject& theSObject, int reason ){return false;}; virtual bool modifyNB_Notification(const char* theVarName){return false;}; - virtual void RegisterGenObj (const std::string& theIOR) {} - virtual void UnRegisterGenObj(const std::string& theIOR) {} }; #endif diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx index 4d26ae7a9..cbe8fc71e 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx @@ -148,7 +148,6 @@ void SALOMEDSImpl_Study::Init() _builder = new SALOMEDSImpl_StudyBuilder(this); _cb = new SALOMEDSImpl_Callback(_useCaseBuilder); _notifier=0; - _genObjRegister=0; //Put on the root label a StudyHandle attribute to store the address of this object //It will be used to retrieve the study object by DF_Label that belongs to the study SALOMEDSImpl_StudyHandle::Set(_doc->Main().Root(), this); @@ -3199,49 +3198,6 @@ void SALOMEDSImpl_Study::setNotifier(SALOMEDSImpl_AbstractCallback* notifier) _notifier=notifier; } -static SALOMEDSImpl_AbstractCallback* & getGenObjRegister( DF_Document* doc ) -{ - static std::vector< SALOMEDSImpl_AbstractCallback* > _genObjRegVec; - if ( doc->GetDocumentID() >= (int)_genObjRegVec.size() ) - _genObjRegVec.resize( doc->GetDocumentID() + 1, 0 ); - return _genObjRegVec[ doc->GetDocumentID() ]; -} - -//================================================================================ -/*! - * \brief Stores theRegister - */ -//================================================================================ - -void SALOMEDSImpl_Study::setGenObjRegister(SALOMEDSImpl_AbstractCallback* theRegister) -{ - getGenObjRegister( _doc ) = theRegister; -} - -//================================================================================ -/*! - * \brief Indirectly invokes GenericObj_i::Register() - */ -//================================================================================ - -void SALOMEDSImpl_Study::RegisterGenObj (const std::string& theIOR, DF_Label label) -{ - if ( SALOMEDSImpl_AbstractCallback* goRegister = getGenObjRegister( label.GetDocument() )) - goRegister->RegisterGenObj( theIOR ); -} - -//================================================================================ -/*! - * \brief Indirectly invokes GenericObj_i::UnRegister() - */ -//================================================================================ - -void SALOMEDSImpl_Study::UnRegisterGenObj(const std::string& theIOR, DF_Label label) -{ - if ( SALOMEDSImpl_AbstractCallback* goRegister = getGenObjRegister( label.GetDocument() )) - goRegister->UnRegisterGenObj( theIOR ); -} - //####################################################################################################### //# STATIC PRIVATE FUNCTIONS //####################################################################################################### diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_Study.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_Study.hxx index bd8f55faf..ff30a54c1 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_Study.hxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_Study.hxx @@ -72,7 +72,6 @@ private: SALOMEDSImpl_StudyBuilder* _builder; SALOMEDSImpl_UseCaseBuilder* _useCaseBuilder; SALOMEDSImpl_AbstractCallback* _notifier; - SALOMEDSImpl_AbstractCallback* _genObjRegister; std::map _mapOfSO; std::map _mapOfSCO; @@ -361,10 +360,6 @@ public: virtual bool modifySO_Notification(const SALOMEDSImpl_SObject& theSObject, int reason); virtual void setNotifier(SALOMEDSImpl_AbstractCallback* notifier); - static void RegisterGenObj (const std::string& theIOR, DF_Label label); - static void UnRegisterGenObj(const std::string& theIOR, DF_Label label); - void setGenObjRegister(SALOMEDSImpl_AbstractCallback* theRegister); - friend class SALOMEDSImpl_GenericAttribute; friend class SALOMEDSImpl_GenericVariable; }; diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_StudyBuilder.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_StudyBuilder.cxx index f3e530112..bf0c5ea0a 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_StudyBuilder.cxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_StudyBuilder.cxx @@ -1014,10 +1014,7 @@ static void Translate_persistentID_to_IOR(DF_Label& Lab, SALOMEDSImpl_Driver* dr persist_ref, isMultiFile, isASCII); - SALOMEDSImpl_AttributeIOR* iorAttr = SALOMEDSImpl_AttributeIOR::Set (current, ior_string); - - // make myRefCounter of a loaded GenericObj == 1 - SALOMEDSImpl_Study::UnRegisterGenObj( ior_string, iorAttr->Label()); + SALOMEDSImpl_AttributeIOR::Set (current, ior_string); } Translate_persistentID_to_IOR (current, driver, isMultiFile, isASCII); } -- 2.39.2