]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
Communicate Session servant created into Session_ServerLauncher thread to the main...
authorAnthony Geay <anthony.geay@edf.fr>
Thu, 18 Feb 2021 12:43:41 +0000 (13:43 +0100)
committerAnthony Geay <anthony.geay@edf.fr>
Thu, 18 Feb 2021 12:43:41 +0000 (13:43 +0100)
src/Session/CMakeLists.txt
src/Session/SALOME_Session_Server.cxx
src/Session/Session_Promises.cxx [new file with mode: 0644]
src/Session/Session_Promises.hxx [new file with mode: 0644]
src/Session/Session_ServerThread.cxx

index 50358adae3b6c43ff5dfdae0fa74d4bb3eb7a99e..77038452fa8b8df0c429594bb092cfa75b92a3e1 100644 (file)
@@ -81,6 +81,7 @@ SET(SalomeSession_HEADERS
   Session_ServerLauncher.hxx
   Session_ServerThread.hxx
   Session_Session_i.hxx
+  Session_Promises.hxx
 )
 
 # --- resources ---
@@ -98,6 +99,7 @@ SET(SalomeSession_SOURCES
   Session_ServerLauncher.cxx
   Session_ServerThread.cxx
   Session_Session_i.cxx
+  Session_Promises.cxx
 )
 
 # --- rules ---
index 38417eed61a74400f4dc3bbe01466159148c635f..8c516411a21f10b061653a0f92031c676ab5ffd1 100644 (file)
@@ -37,6 +37,7 @@
 #include "Session_Session_i.hxx"
 #include "Session_ServerCheck.hxx"
 #include "Session_ServerLauncher.hxx"
+#include "Session_Promises.hxx"
 
 #include "GUI_version.h"
 #include "Qtx.h"
@@ -449,8 +450,9 @@ void GUIAppOldStyle::shutdownRemoteServersIfNeeded(bool remoteLauncher)
 
 SALOME::Session_var GUIAppNewStyle::getSession()
 {
-  /*SALOMEDS::Study_var session = KERNEL::getStudyServantSA();
-  return session;*/
+  GetSessionRefSingleton()->get_future().wait();
+  SALOME::Session_var session = GetSessionRefSingleton()->get_future().get();
+  return session;
 }
 
 // ---------------------------- MAIN -----------------------
diff --git a/src/Session/Session_Promises.cxx b/src/Session/Session_Promises.cxx
new file mode 100644 (file)
index 0000000..b3a8d7d
--- /dev/null
@@ -0,0 +1,26 @@
+// Copyright (C) 2021  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "Session_Promises.hxx"
+
+std::promise<SALOME::Session_var> *GetSessionRefSingleton()
+{
+    static std::promise<SALOME::Session_var> _my_unique_study_ref;
+    return &_my_unique_study_ref;
+}
diff --git a/src/Session/Session_Promises.hxx b/src/Session/Session_Promises.hxx
new file mode 100644 (file)
index 0000000..be47159
--- /dev/null
@@ -0,0 +1,27 @@
+// Copyright (C) 2021  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#pragma once
+
+#include "SALOMEconfig.h"
+#include CORBA_SERVER_HEADER(SALOME_Session)
+
+#include <future>
+
+std::promise<SALOME::Session_var> *GetSessionRefSingleton();
index 7e4b6747357d32cdec09a108610ad9167eb75b58..4e7e65f548dfe0e43717eb3b3fbe65aaaff9df75 100644 (file)
@@ -25,6 +25,7 @@
 //  Author : Paul RASCLE, EDF
 
 #include "Session_ServerThread.hxx"
+#include "Session_Promises.hxx"
 
 #include <SALOME_NamingService.hxx>
 #include <SALOME_Container_i.hxx>
@@ -426,6 +427,8 @@ void Session_SessionThread::ActivateSession(int argc, char ** argv)
     MESSAGE("poa->activate_object(mySALOME_Session)");
     
     CORBA::Object_var obj = mySALOME_Session->_this();
+    SALOME::Session_var objC = SALOME::Session::_narrow(obj);
+    GetSessionRefSingleton()->set_value(objC);
     CORBA::String_var sior(_orb->object_to_string(obj));
     mySALOME_Session->_remove_ref();