From 8454eba12d2f0a874e187e91b56902f3f3976db8 Mon Sep 17 00:00:00 2001 From: Viktor UZLOV Date: Wed, 13 Oct 2021 10:01:10 +0300 Subject: [PATCH] bos #26457 Factorization of ORB initialization --- src/SalomeApp/CMakeLists.txt | 2 +- src/SalomeApp/SalomeApp_Application.cxx | 8 ++++---- src/SalomeApp/SalomeApp_Engine_i.cxx | 8 ++++---- src/Session/CMakeLists.txt | 1 + src/Session/SALOME_Session_Server.cxx | 6 +++--- src/Session/Session_NS_wrapper.cxx | 11 ++++++----- src/Session/Session_ServerCheck.cxx | 1 - src/Session/Session_ServerThread.cxx | 4 +--- 8 files changed, 20 insertions(+), 21 deletions(-) diff --git a/src/SalomeApp/CMakeLists.txt b/src/SalomeApp/CMakeLists.txt index d43b4339d..041e59c78 100644 --- a/src/SalomeApp/CMakeLists.txt +++ b/src/SalomeApp/CMakeLists.txt @@ -76,7 +76,7 @@ SET(_link_LIBRARIES ${OpenCASCADE_FoundationClasses_LIBRARIES} ${QT_LIBRARIES} ${PYTHON_LIBRARIES} - ${KERNEL_OpUtil} ${KERNEL_SALOMELocalTrace} ${KERNEL_SalomeDSClient} ${KERNEL_TOOLSDS} + ${KERNEL_ArgvKeeper} ${KERNEL_OpUtil} ${KERNEL_SALOMELocalTrace} ${KERNEL_SalomeDSClient} ${KERNEL_TOOLSDS} CASCatch suit std CAM ObjBrowser SalomePrs Event LogWindow LightApp SalomePrs ToolsGUI ) diff --git a/src/SalomeApp/SalomeApp_Application.cxx b/src/SalomeApp/SalomeApp_Application.cxx index 19d097379..aedddec2a 100644 --- a/src/SalomeApp/SalomeApp_Application.cxx +++ b/src/SalomeApp/SalomeApp_Application.cxx @@ -80,8 +80,6 @@ //#include -#include -#include #include #include @@ -97,7 +95,9 @@ #include #include +#include #include +#include #include #include @@ -1347,8 +1347,8 @@ CORBA::ORB_var SalomeApp_Application::orb() if ( CORBA::is_nil( _orb ) ) { Qtx::CmdLineArgs args; - ORB_INIT& init = *SINGLETON_::Instance(); - _orb = init( args.argc(), args.argv() ); + SetArgcArgv( args.argc(), args.argv() ); + _orb = KERNEL::GetRefToORB(); } return _orb; diff --git a/src/SalomeApp/SalomeApp_Engine_i.cxx b/src/SalomeApp/SalomeApp_Engine_i.cxx index a7490d7b8..760822ae9 100644 --- a/src/SalomeApp/SalomeApp_Engine_i.cxx +++ b/src/SalomeApp/SalomeApp_Engine_i.cxx @@ -33,8 +33,8 @@ #include #include -#include -#include +#include +#include #include #include @@ -343,8 +343,8 @@ CORBA::ORB_var SalomeApp_Engine_i::orb() if ( CORBA::is_nil( _orb ) ) { Qtx::CmdLineArgs args; - ORB_INIT& init = *SINGLETON_::Instance(); - _orb = init( args.argc(), args.argv() ); + SetArgcArgv( args.argc(), args.argv() ); + _orb = KERNEL::GetRefToORB(); } return _orb; diff --git a/src/Session/CMakeLists.txt b/src/Session/CMakeLists.txt index 480715f57..fe934c25a 100644 --- a/src/Session/CMakeLists.txt +++ b/src/Session/CMakeLists.txt @@ -57,6 +57,7 @@ SET(_link_LIBRARIES ${QT_LIBRARIES} ${OpenCASCADE_FoundationClasses_LIBRARIES} ${OMNIORB_LIBRARIES} + ${KERNEL_ArgvKeeper} ${KERNEL_SalomeNS} ${KERNEL_SalomeLifeCycleCORBA} ${KERNEL_OpUtil} diff --git a/src/Session/SALOME_Session_Server.cxx b/src/Session/SALOME_Session_Server.cxx index e95d71ee5..253fd8f22 100644 --- a/src/Session/SALOME_Session_Server.cxx +++ b/src/Session/SALOME_Session_Server.cxx @@ -20,6 +20,7 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // +#include #include // this include must be the first one as it includes Python.h #include #include @@ -579,15 +580,14 @@ int AbstractGUIAppMain(int argc, char **argv) try { // ...create ORB, get RootPOA object, NamingService, etc. - ORB_INIT &init = *SINGLETON_::Instance(); - ASSERT(SINGLETON_::IsAlreadyExisting()); int orbArgc = 1; if (std::string(argv[1]).find("-ORBInitRef") != std::string::npos) { orbArgc = 3; remoteLauncher = true; } - orb = init(orbArgc, argv); + SetArgcArgv(orbArgc, argv); + orb = KERNEL::GetRefToORB(); CORBA::Object_var obj = orb->resolve_initial_references("RootPOA"); poa = PortableServer::POA::_narrow(obj); diff --git a/src/Session/Session_NS_wrapper.cxx b/src/Session/Session_NS_wrapper.cxx index 2619179e4..a90359c4b 100644 --- a/src/Session/Session_NS_wrapper.cxx +++ b/src/Session/Session_NS_wrapper.cxx @@ -19,6 +19,8 @@ #include "Session_NS_wrapper.hxx" +#include "ArgvKeeper.hxx" +#include "OpUtil.hxx" #include "SALOME_Fake_NamingService.hxx" #include "SALOME_Container_i.hxx" #include "SALOME_Launcher.hxx" @@ -199,13 +201,12 @@ void OldStyleNS::activateSALOMEDS(CORBA::ORB_var orb, PortableServer::POA_var po } } -#include "Utils_ORB_INIT.hxx" #include "Utils_SINGLETON.hxx" CORBA::Object_var OldStyleNS::forServerChecker(const char *NSName, int argc, char **argv) { - ORB_INIT& init = *SINGLETON_::Instance(); - CORBA::ORB_var orb = init( argc, argv ); + SetArgcArgv( argc, argv ); + CORBA::ORB_var orb = KERNEL::GetRefToORB(); SALOME_NamingService &NS = *SINGLETON_::Instance(); ASSERT( SINGLETON_::IsAlreadyExisting() ); NS.init_orb( orb ); @@ -216,8 +217,8 @@ CORBA::Object_var OldStyleNS::forServerChecker(const char *NSName, int argc, cha CosNaming::NamingContext_var OldStyleNS::checkTrueNamingServiceIfExpected(int argc, char **argv, bool& forceOK) { forceOK = false;//tell checker : do as before - ORB_INIT& init = *SINGLETON_::Instance(); - CORBA::ORB_var orb = init( argc, argv ); + SetArgcArgv( argc, argv ); + CORBA::ORB_var orb = KERNEL::GetRefToORB(); CORBA::Object_var obj = orb->resolve_initial_references( "NameService" ); CosNaming::NamingContext_var _root_context = CosNaming::NamingContext::_narrow( obj ); return _root_context; diff --git a/src/Session/Session_ServerCheck.cxx b/src/Session/Session_ServerCheck.cxx index 882e37470..db8299ea3 100644 --- a/src/Session/Session_ServerCheck.cxx +++ b/src/Session/Session_ServerCheck.cxx @@ -32,7 +32,6 @@ #include CORBA_CLIENT_HEADER(SALOME_ModuleCatalog) #include CORBA_CLIENT_HEADER(SALOME_Component) -#include "Utils_ORB_INIT.hxx" #include "Utils_SINGLETON.hxx" #include "SALOME_NamingService.hxx" #include "Basics_Utils.hxx" diff --git a/src/Session/Session_ServerThread.cxx b/src/Session/Session_ServerThread.cxx index d508588d7..66cf53f8b 100644 --- a/src/Session/Session_ServerThread.cxx +++ b/src/Session/Session_ServerThread.cxx @@ -35,9 +35,7 @@ #include "Session_Session_i.hxx" -#include -#include -#include +#include #include #include #include -- 2.39.2