]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
Fix SUGSEGV on desktop closing if Sweep window is open V5_1_2 V5_1_2rc5 mergeto_V5_1_main_14Jul09
authorvsr <vsr@opencascade.com>
Mon, 6 Jul 2009 10:32:57 +0000 (10:32 +0000)
committervsr <vsr@opencascade.com>
Mon, 6 Jul 2009 10:32:57 +0000 (10:32 +0000)
src/VISUGUI/VisuGUI_Tools.cxx

index 9d150f1b38bf0f51a6c6cd4f8841bfcc55b54314..0060ee78e9d92296ed9a9ddf5668c900fd64eb4f 100644 (file)
@@ -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<SalomeApp_Study*>(theModule->application()->activeStudy());
+    return theModule && theModule->application() ? 
+      dynamic_cast<SalomeApp_Study*>(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;
   }