Salome HOME
updated copyright message
[modules/gui.git] / src / Session / SALOME_Session_Server.cxx
index 13271628d807bf95be18b482e4fae41211482d19..9feac2fc0ec76ad6c147193f06b16e5ff093156d 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2020  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2023  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
@@ -20,9 +20,9 @@
 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 
+#include <ArgvKeeper.hxx>
 #include <Container_init_python.hxx> // this include must be the first one as it includes Python.h
 #include <Basics_Utils.hxx>
-#include <ConnectionManager_i.hxx>
 #include <OpUtil.hxx>
 #include <RegistryService.hxx>
 #include <SALOME_LifeCycleCORBA.hxx>
@@ -33,6 +33,7 @@
 #include <Utils_SALOME_Exception.hxx>
 #include <Utils_SINGLETON.hxx>
 #include <utilities.h>
+#include "KernelBasis.hxx"
 
 #include "Session_Session_i.hxx"
 #include "Session_ServerCheck.hxx"
 #include <QTextStream>
 #include <QWaitCondition>
 
+#ifdef WIN32
+extern "C" {
+// For DWORD (see end of file)
+#include "windef.h"
+// Force high-performance graphics on dual-GPU systems
+  // http://developer.download.nvidia.com/devzone/devcenter/gamegraphics/files/OptimusRenderingPolicies.pdf
+  __declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001;
+  // https://community.amd.com/thread/169965
+  __declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1;
+}
+#endif
+
 //! CORBA server for SALOME GUI session
 /*!
  * SALOME_Session_Server launches a SALOME session servant.
@@ -383,6 +396,7 @@ int AbstractGUIAppMain(int argc, char **argv);
 class GUIAppOldStyle
 {
 public:
+  static constexpr bool SSL_MODE = false;
   using NamingServiceImplementation = OldStyleNS;
   void connectToNSIfNeeded(CORBA::ORB_ptr orb) { _NS.reset(new SALOME_NamingService(orb)); }
   void shutdownCORBAStufIfNeeded(bool shutdownAll, CORBA::ORB_ptr orb);
@@ -396,6 +410,7 @@ private:
 class GUIAppNewStyle
 {
 public:
+  static constexpr bool SSL_MODE = true;
   using NamingServiceImplementation = NewStyleNS;
   void connectToNSIfNeeded(CORBA::ORB_ptr orb) { /*! nothing */ }
   void shutdownCORBAStufIfNeeded(bool shutdownAll, CORBA::ORB_ptr orb) { /*! nothing */ }
@@ -451,6 +466,8 @@ template<class GUI_APP_STYLE>
 int AbstractGUIAppMain(int argc, char **argv)
 {
   using NamingServiceImplementation = typename GUI_APP_STYLE::NamingServiceImplementation;
+  setSSLMode(GUI_APP_STYLE::SSL_MODE);
+  setGUIMode(true);
   GUI_APP_STYLE self;
   // Set-up application settings configuration (as for QSettings)
   // Note: these are default settings which can be customized (see below)
@@ -478,6 +495,7 @@ int AbstractGUIAppMain(int argc, char **argv)
 
   // Create Qt application instance: this should be done as early as possible!
   // Note: QApplication forces setting locale LC_ALL to system one: setlocale(LC_ALL, "").
+  SetArgcArgv(argc,argv);
   Application app(argc, argv);
 
   // Initialize Python (only once)
@@ -507,6 +525,15 @@ int AbstractGUIAppMain(int argc, char **argv)
     QLocale::setDefault(QLocale::c());
   resMgr.setWorkingMode(ResourceMgr::IgnoreUserValues);
 
+#if defined(GLOBAL_DOUBLE_CONVERSION)
+  // VSR 30/03/2021: moved here from QtxDoubleSpinBox/QtxIntSpinBox because of crash on Qt 5.12.
+  // Disable thousands separator for spin box
+  // see issue 14540 (old id 21219)
+  QLocale locale;
+  locale.setNumberOptions(locale.numberOptions() | QLocale::OmitGroupSeparator | QLocale::RejectGroupSeparator);
+  QLocale::setDefault(locale);
+#endif
+
   bool isGUI = boolCmdOption("--show-desktop", "--hide-desktop", true);  // true by default
   bool isSplash = boolCmdOption("--show-splash", "--hide-splash", true); // true by default
 
@@ -553,15 +580,14 @@ int AbstractGUIAppMain(int argc, char **argv)
   try
   {
     // ...create ORB, get RootPOA object, NamingService, etc.
-    ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance();
-    ASSERT(SINGLETON_<ORB_INIT>::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);