Salome HOME
Copyright update 2022
[tools/yacsgen.git] / Examples / cppgui1 / cppcomposGUI.cxx
index ec6f48fdea1eb3f36cc937f0c8591720113be1a4..177b9a67d889989f26cb29bcae340147957b77b0 100644 (file)
@@ -1,9 +1,9 @@
-// Copyright (C) 2009-2012  EDF R&D
+// Copyright (C) 2009-2022  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
 // 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
@@ -24,6 +24,7 @@
 #include <SUIT_Study.h>
 #include <SalomeApp_Application.h>
 #include <SALOME_LifeCycleCORBA.hxx>
+#include <SALOME_KernelServices.hxx>
 
 #include <SALOMEconfig.h>
 #include CORBA_CLIENT_HEADER(cppcompos)
@@ -100,10 +101,7 @@ bool cppcomposGUI::activateModule( SUIT_Study* theStudy )
   setMenuShown( true );
   setToolShown( true );
 
-  SALOME_NamingService *aNamingService = SalomeApp_Application::namingService();
-  CORBA::Object_var aSMObject = aNamingService->Resolve("/myStudyManager");
-  SALOMEDS::StudyManager_var aStudyManager = SALOMEDS::StudyManager::_narrow(aSMObject);
-  SALOMEDS::Study_var aDSStudy = aStudyManager->GetStudyByID(theStudy->id());
+  SALOMEDS::Study_var aDSStudy = KERNEL::getStudyServant();
 
   SALOMEDS::SComponent_var aFather = aDSStudy->FindComponent("cppcompos");
   if (aFather->_is_nil())
@@ -117,7 +115,7 @@ bool cppcomposGUI::activateModule( SUIT_Study* theStudy )
       aStudyBuilder->DefineComponentInstance(aFather, engine);
     }
   CORBA::Boolean valid;
-  engine->DumpPython(aDSStudy,1,0,valid);
+  engine->DumpPython(1,0,valid);
 
   return bOk;
 }
@@ -135,7 +133,7 @@ bool cppcomposGUI::deactivateModule( SUIT_Study* theStudy )
 void cppcomposGUI::OnGetBanner()
 {
   // Dialog to get the Name
-  bool ok = FALSE;
+  bool ok = false;
   QString myName = QInputDialog::getText( getApp()->desktop(), "label", "name", QLineEdit::Normal, QString::null, &ok );
 
   if ( ok && !myName.isEmpty())