]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
Fix problem of multiple study servant in GUI case generating empty notifiers list... agy/archi5_integ
authorAnthony Geay <anthony.geay@edf.fr>
Wed, 24 Feb 2021 14:09:07 +0000 (15:09 +0100)
committerAnthony Geay <anthony.geay@edf.fr>
Wed, 24 Feb 2021 14:09:07 +0000 (15:09 +0100)
src/SALOMEDS/SALOMEDS.cxx
src/SALOMEDS/SALOMEDS_Study_i.cxx
src/SALOMEDS/SALOMEDS_Study_i.hxx

index 0ce9dc1f4043fe88340392b05dd8b37c2059d648..bd1c112b66994138de24829834008ef9ef675000 100644 (file)
@@ -129,6 +129,7 @@ extern "C"
       // Activate the objects.  This tells the POA that the objects are ready to accept requests.
       PortableServer::ObjectId_var aStudy_iid =  root_poa->activate_object(aStudy_i);
       aStudy = aStudy_i->_this();
+      KERNEL::setStudyServantSA(aStudy,poa);
       namingService.Register(aStudy, "/Study");
       aStudy_i->GetImpl()->GetDocument()->SetModified(false);
       aStudy_i->_remove_ref();
index 79ad8c553ff17738fb6b1a735c284ca53a8fe9e8..60961b89165fc49fa1d2dd5c329f53486b6607e6 100644 (file)
@@ -64,7 +64,8 @@ UNEXPECT_CATCH(LockProtection, SALOMEDS::StudyBuilder::LockProtection)
 
 static SALOMEDS_Driver_i* GetDriver(const SALOMEDSImpl_SObject& theObject, CORBA::ORB_ptr orb);
 
-static PortableServer::POA_ptr _poa;
+static PortableServer::POA_var _poa;
+static SALOMEDS::Study_var _study;
 
 /**
  * Return a unique study obj but servant is embeded here.
@@ -72,17 +73,36 @@ static PortableServer::POA_ptr _poa;
  */
 SALOMEDS::Study_ptr KERNEL::getStudyServantSA()
 {
-  static SALOMEDS::Study_ptr aStudy;
-  if(CORBA::is_nil(aStudy))
+
+  if(CORBA::is_nil(_study))
   {
     CORBA::ORB_ptr orb = KERNEL::getORB();
     CORBA::Object_var obj = orb->resolve_initial_references("RootPOA");
     PortableServer::POA_var poa = PortableServer::POA::_narrow(obj);
     _poa = PortableServer::POA::_duplicate(poa);
     SALOMEDS_Study_i *servant = new SALOMEDS_Study_i(orb,SALOME::Session::_nil());
-    aStudy = servant->_this();
+    _study = servant->_this();
+  }
+  return SALOMEDS::Study::_duplicate(_study);
+}
+
+/**
+ * If a study is already built and activated elsewhere (for example in GUI context)
+ */
+void KERNEL::setStudyServantSA(SALOMEDS::Study_var study, PortableServer::POA_var poa)
+{
+  if( ! CORBA::is_nil(_study) )
+  {
+    PortableServer::ServantBase *serv = nullptr;
+    try
+    {
+      serv = _poa->reference_to_servant(_study);
+    }
+    catch(...) { }
+    if(serv)
+      serv->_remove_ref();
   }
-  return SALOMEDS::Study::_duplicate(aStudy);
+  _study = study; _poa = poa;
 }
 
 namespace SALOMEDS
index 8f3b34ef764d114976a52acb4441c9df3d91e07d..37a44de5fe61b95c4817cc6075b1e6434dc9349b 100644 (file)
@@ -51,6 +51,7 @@ class SALOME_NamingService_Abstract;
 namespace KERNEL
 {
   Standard_EXPORT SALOMEDS::Study_ptr getStudyServantSA();
+  Standard_EXPORT void setStudyServantSA(SALOMEDS::Study_var study, PortableServer::POA_var poa);
 }
 
 class Standard_EXPORT SALOMEDS_Study_i: public POA_SALOMEDS::Study