Salome HOME
Merge Qt5 porting.
[modules/gui.git] / src / SalomeApp / SalomeApp_Engine_i.cxx
index c8d71de18dff415685727e06aad6f63fff9ea063..b26a8424cb7b8c9a0b736e6684cfd298b0159663 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2014  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2015  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
@@ -302,10 +302,24 @@ 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 ) ) {
+    QStringList args = QApplication::arguments();
+    int argc = args.size();
+    std::vector<std::string> args1(argc);
+    char** argv = new char*[argc];
+    for ( int i = 0; i < argc; ++i ) {
+      args1[i] = args[i].toStdString();
+      argv[i]  = const_cast<char*>( args1[i].c_str() );
+    }
+
+    ORB_INIT& init = *SINGLETON_<ORB_INIT>::Instance();
+    _orb = init( argc, argv );
+
+    delete [] argv;
+  }
+
   return _orb;
 }
 
@@ -340,7 +354,7 @@ 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;
@@ -384,7 +398,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 +416,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() );