From: vsr Date: Thu, 15 Oct 2009 17:29:34 +0000 (+0000) Subject: Fix problem with memory management in VISU (SIGSEGV on VISU module activation in... X-Git-Tag: V5_1_main_20091019~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=f09870ddef10c5a40e0ba9e0bead61cd160012e8;p=modules%2Fvisu.git Fix problem with memory management in VISU (SIGSEGV on VISU module activation in second study) --- diff --git a/src/VISUGUI/VisuGUI_Tools.cxx b/src/VISUGUI/VisuGUI_Tools.cxx index 4748228c..4b5ffa39 100644 --- a/src/VISUGUI/VisuGUI_Tools.cxx +++ b/src/VISUGUI/VisuGUI_Tools.cxx @@ -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; } diff --git a/src/VISU_I/VISU_Gen_i.cc b/src/VISU_I/VISU_Gen_i.cc index 0dd7a7b5..c63600c3 100644 --- a/src/VISU_I/VISU_Gen_i.cc +++ b/src/VISU_I/VISU_Gen_i.cc @@ -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(); + } //---------------------------------------------------------------