Salome HOME
Merge remote-tracking branch 'origin/V8_3_BR' into ngr/python3_dev
[modules/gui.git] / src / SalomeApp / SalomeApp_Engine_i.cxx
index ff4db43b9fcd7fd4a06cba7a8a94b9a92f5e7e19..16c1fcc29fdbebf2f92f01983c0ac65bc9ae8652 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2016  CEA/DEN, EDF R&D, OPEN CASCADE
 //
 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
@@ -6,7 +6,7 @@
 // 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.
+// 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
@@ -302,10 +302,14 @@ char* SalomeApp_Engine_i::getVersion()
 */
 CORBA::ORB_var SalomeApp_Engine_i::orb()
 {
-  ORB_INIT& init = *SINGLETON_<ORB_INIT>::Instance();
-  // TODO: using QApplication here looks ugly, think how to
-  // obtain the ORB reference in a nicer way...
-  static CORBA::ORB_var _orb = init( qApp->argc(), qApp->argv() );
+  static CORBA::ORB_var _orb;
+
+  if ( CORBA::is_nil( _orb ) ) {
+    Qtx::CmdLineArgs args;
+    ORB_INIT& init = *SINGLETON_<ORB_INIT>::Instance();
+    _orb = init( args.argc(), args.argv() );
+  }
+
   return _orb;
 }
 
@@ -340,13 +344,16 @@ SALOME_NamingService* SalomeApp_Engine_i::namingService()
   \param theComponentName - synthetic "component data type" used to identify a given light module
   \return Object reference to the CORBA engine
 */
-CORBA::Object_ptr SalomeApp_Engine_i::engineForComponent( const char* theComponentName,
+CORBA::Object_ptr SalomeApp_Engine_i::EngineForComponent( const char* theComponentName,
                                                          bool toCreate )
 {
   CORBA::Object_var anEngine;
   if ( !theComponentName || !strlen( theComponentName ) )
     return anEngine._retn();
 
+  if ( SalomeApp_Application::moduleTitle( theComponentName ).isEmpty() )
+    return anEngine._retn();
+
   std::string aPath( "/SalomeAppEngine/" );
   aPath += theComponentName;
   anEngine = namingService()->Resolve( aPath.c_str() );
@@ -384,7 +391,7 @@ std::string SalomeApp_Engine_i::EngineIORForComponent( const char* theComponentN
                                                       bool toCreate )
 {
   std::string anIOR( "" );
-  CORBA::Object_var anEngine = engineForComponent( theComponentName, toCreate );
+  CORBA::Object_var anEngine = EngineForComponent( theComponentName, toCreate );
   if ( !CORBA::is_nil( anEngine ) )
   {
     CORBA::String_var objStr = orb()->object_to_string( anEngine.in() );
@@ -402,7 +409,7 @@ SalomeApp_Engine_i* SalomeApp_Engine_i::GetInstance( const char* theComponentNam
                                                     bool toCreate )
 {
   SalomeApp_Engine_i* aServant = 0;
-  CORBA::Object_var anEngine = engineForComponent( theComponentName, toCreate );
+  CORBA::Object_var anEngine = EngineForComponent( theComponentName, toCreate );
   if ( !CORBA::is_nil( anEngine ) )
   {
     PortableServer::Servant aServantBase = poa()->reference_to_servant( anEngine.in() );