Salome HOME
[EDF27816] : in case of UsingPythonCache disabled (default) all temporary variables...
[modules/yacs.git] / src / genericgui / GenericGui.cxx
index 023a88cfd4ffb38c122947386a9585e7e56a53db..6b954d4647ca5f1e7fd5429516aad2963690b41c 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2006-2015  CEA/DEN, EDF R&D
+// Copyright (C) 2006-2022  CEA/DEN, EDF R&D
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
@@ -30,7 +30,8 @@
 #include "YACSGuiLoader.hxx"
 #include "ComponentInstance.hxx"
 
-#include "SALOME_NamingService.hxx"
+#include "ServiceUnreachable.hxx"
+#include "SALOME_NamingService_Wrapper.hxx"
 #include "SALOME_ModuleCatalog.hxx"
 #include "SALOME_ModuleCatalog.hh"
 #include "SALOMEDS_Tool.hxx"
@@ -115,7 +116,7 @@ GenericGui::GenericGui(YACS::HMI::SuitWrapper* wrapper, QMainWindow *parent)
       CORBA::ORB_ptr orb = runTime->getOrb();
       if (orb)
         {
-          SALOME_NamingService namingService(orb);
+          SALOME_NamingService_Wrapper namingService(orb);
           CORBA::Object_ptr obj = namingService.Resolve("/Kernel/ModulCatalog");
           SALOME_ModuleCatalog::ModuleCatalog_var aModuleCatalog =
             SALOME_ModuleCatalog::ModuleCatalog::_narrow(obj);
@@ -172,10 +173,9 @@ GenericGui::GenericGui(YACS::HMI::SuitWrapper* wrapper, QMainWindow *parent)
   _dwCatalogs->setWidget(_catalogsWidget);
 
   _parent->tabifyDockWidget(_dwStacked, _dwCatalogs);
-  _parent->tabifyDockWidget(_dwTree, _wrapper->objectBrowser());
-#if QT_VERSION >= 0x040500
+  if (_wrapper->objectBrowser())
+    _parent->tabifyDockWidget(_dwTree, _wrapper->objectBrowser());
   _parent->setTabPosition(Qt::AllDockWidgetAreas, Resource::tabPanelsUp? QTabWidget::North: QTabWidget::South);
-#endif
   //Import user catalog
   std::string usercata=Resource::userCatalog.toStdString();
   _catalogsWidget->addCatalogFromFile(usercata);
@@ -968,19 +968,15 @@ bool GenericGui::closeContext(QWidget *view, bool onExit)
           break;
         }
     }
-  int studyId = _wrapper->activeStudyId();
-  if (context->getStudyId() == studyId)
+  _wrapper->deleteSchema(view);
+  DEBTRACE("delete context");
+  if (GuiExecutor* exec = context->getGuiExecutor())
     {
-      _wrapper->deleteSchema(view);
-      DEBTRACE("delete context");
-      if (GuiExecutor* exec = context->getGuiExecutor())
-        {
-          exec->closeContext();
-        }
-      delete context;
-      _mapViewContext.erase(view);
-      switchContext(newView, onExit);
+      exec->closeContext();
     }
+  delete context;
+  _mapViewContext.erase(view);
+  switchContext(newView, onExit);
   return true;
 }
 
@@ -1008,7 +1004,7 @@ std::list<std::string> GenericGui::getMachineList()
   CORBA::ORB_ptr orb = runTime->getOrb();
   if (!orb) return _machineList;
 
-  SALOME_NamingService namingService(orb);
+  SALOME_NamingService_Wrapper namingService(orb);
   SALOME_LifeCycleCORBA lcc(&namingService);
 
   CORBA::Object_var obj =
@@ -1092,11 +1088,7 @@ void GenericGui::createContext(YACS::ENGINE::Proc* proc,
   GraphicsView* gView = new GraphicsView(viewWindow);
   gView->setScene(scene);
   gView->setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
-  int studyId = _wrapper->AssociateViewToWindow(gView, viewWindow);
-  context->setStudyId(studyId);
-  std::ostringstream value;
-  value << studyId;
-  proc->setProperty("DefaultStudyID",value.str());
+  _wrapper->AssociateViewToWindow(gView, viewWindow);
   context->setScene(scene);
   context->setView(gView);
   context->setWindow(viewWindow);
@@ -2588,7 +2580,6 @@ void GenericGui::onShowRedo()
 void GenericGui::onCleanOnExit()
 {
   DEBTRACE("GenericGui::onCleanOnExit");
-  int studyId = _wrapper->activeStudyId();
   map<QWidget*, YACS::HMI::QtGuiContext*> mapViewContextCopy = _mapViewContext;
   map<QWidget*, YACS::HMI::QtGuiContext*>::iterator it = mapViewContextCopy.begin();
   for (; it != mapViewContextCopy.end(); ++it)