]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
Fix problem with memory management in VISU (SIGSEGV on VISU module activation in...
authorvsr <vsr@opencascade.com>
Thu, 15 Oct 2009 17:29:34 +0000 (17:29 +0000)
committervsr <vsr@opencascade.com>
Thu, 15 Oct 2009 17:29:34 +0000 (17:29 +0000)
src/VISUGUI/VisuGUI_Tools.cxx
src/VISU_I/VISU_Gen_i.cc

index 4748228c14b6503032c31862c1c168916063e586..4b5ffa39713562e297cdaaac525668954dc0869f 100644 (file)
@@ -215,17 +215,18 @@ namespace VISU
   VISU_Gen_i*
   GetVisuGen(const CAM_Module* theModule)
   {
-    static VISU_Gen_i* aGen = NULL;
+    static VISU_Gen_i* aGen = 0;
     if(!aGen){
       SALOME_LifeCycleCORBA aLCC(SalomeApp_Application::namingService());
       Engines::Component_var aComponent = aLCC.FindOrLoad_Component("FactoryServer","VISU");
       VISU_Gen_var aVISU = VISU_Gen::_narrow(aComponent);
-      if(!CORBA::is_nil(aVISU)){
-       if((aGen = VISU_Gen_i::GetVisuGenImpl()))
-         aGen->SetCurrentStudy(GetDSStudy(GetCStudy(GetAppStudy(theModule))));
-      }
+      if(!CORBA::is_nil(aVISU))
+       aGen = VISU_Gen_i::GetVisuGenImpl();
     }
-    if(!aGen)
+    
+    if(aGen)
+      aGen->SetCurrentStudy(GetDSStudy(GetCStudy(GetAppStudy(theModule))));
+    else
       throw std::runtime_error(QObject::tr("ERR_CANT_FIND_VISU_COMPONENT").toLatin1().data());
     return aGen;
   }
index 0dd7a7b56914e44423796855823205abb0129227..c63600c36ba9c4697b4fef992138263e58d4aaad 100644 (file)
@@ -1289,7 +1289,11 @@ namespace VISU
   void
   VISU_Gen_i
   ::Close(SALOMEDS::SComponent_ptr theComponent)
-  {}
+  {
+    if ( !CORBA::is_nil( myStudyDocument ) && !CORBA::is_nil( theComponent ) && 
+        myStudyDocument->StudyId() == theComponent->GetStudy()->StudyId())
+      myStudyDocument = SALOMEDS::Study::_nil();
+  }
 
 
   //---------------------------------------------------------------