From: vsr Date: Mon, 6 Jul 2009 10:32:57 +0000 (+0000) Subject: Fix SUGSEGV on desktop closing if Sweep window is open X-Git-Tag: V5_1_2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=191539f7b2d4bc9a0c4eeede602df23305cdf5fd;p=modules%2Fvisu.git Fix SUGSEGV on desktop closing if Sweep window is open --- diff --git a/src/VISUGUI/VisuGUI_Tools.cxx b/src/VISUGUI/VisuGUI_Tools.cxx index 9d150f1b..0060ee78 100644 --- a/src/VISUGUI/VisuGUI_Tools.cxx +++ b/src/VISUGUI/VisuGUI_Tools.cxx @@ -86,38 +86,36 @@ namespace VISU SUIT_Desktop* GetDesktop(const CAM_Module* theModule) { - return theModule->application()->desktop(); + return theModule && theModule->application() ? theModule->application()->desktop() : 0; } //------------------------------------------------------------ LightApp_SelectionMgr* GetSelectionMgr(const SalomeApp_Module* theModule) { - return theModule->getApp()->selectionMgr(); + return theModule && theModule->getApp() ? theModule->getApp()->selectionMgr() : 0; } //------------------------------------------------------------ SalomeApp_Study* GetAppStudy(const CAM_Module* theModule) { - return - dynamic_cast(theModule->application()->activeStudy()); + return theModule && theModule->application() ? + dynamic_cast(theModule->application()->activeStudy()) : 0; } //------------------------------------------------------------ _PTR(Study) GetCStudy(const SalomeApp_Study* theStudy) { - return theStudy->studyDS(); + return theStudy ? theStudy->studyDS() : _PTR(Study)(); } //------------------------------------------------------------ bool IsStudyLocked( _PTR(Study) theStudy ) { - if( theStudy ) - return theStudy->GetProperties()->IsLocked(); - return true; + return theStudy ? theStudy->GetProperties()->IsLocked() : true; } //------------------------------------------------------------ @@ -256,23 +254,25 @@ namespace VISU TSelectionInfo aSelectionInfo; const SalomeApp_Study* aStudy = GetAppStudy(theModule); LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(theModule); - SALOME_ListIO aListIO; - aSelectionMgr->selectedObjects(aListIO); - SALOME_ListIteratorOfListIO anIter(aListIO); - while(anIter.More()) - { - Handle(SALOME_InteractiveObject) anIO = anIter.Value(); - if(anIO->hasEntry()) + if ( aStudy && aSelectionMgr ) { + SALOME_ListIO aListIO; + aSelectionMgr->selectedObjects(aListIO); + SALOME_ListIteratorOfListIO anIter(aListIO); + while(anIter.More()) { - TObjectInfo anObjectInfo = GetObjectByEntry(aStudy, anIO->getEntry()); - if(anObjectInfo.mySObject){ - TSelectionItem aSelectionItem; - aSelectionItem.myObjectInfo = anObjectInfo; - aSelectionItem.myIO = anIO; - aSelectionInfo.push_back(aSelectionItem); + Handle(SALOME_InteractiveObject) anIO = anIter.Value(); + if(anIO->hasEntry()) + { + TObjectInfo anObjectInfo = GetObjectByEntry(aStudy, anIO->getEntry()); + if(anObjectInfo.mySObject){ + TSelectionItem aSelectionItem; + aSelectionItem.myObjectInfo = anObjectInfo; + aSelectionItem.myIO = anIO; + aSelectionInfo.push_back(aSelectionItem); + } } + anIter.Next(); // MULTIPR fixed } - anIter.Next(); // MULTIPR fixed } return aSelectionInfo; }