]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Prevent crash when viewer opened
authorvsv <vitaly.smetannikov@opencascade.com>
Thu, 31 Jul 2014 07:23:39 +0000 (11:23 +0400)
committervsv <vitaly.smetannikov@opencascade.com>
Thu, 31 Jul 2014 07:23:39 +0000 (11:23 +0400)
src/PartSet/PartSet_Module.cpp
src/XGUI/XGUI_Viewer.cpp
src/XGUI/XGUI_ViewerProxy.cpp

index b28152c011924f6074ae5086818dfbda93dd8c6c..611d2a5fd41bb913259a5f8319073d4d0eacf0c6 100644 (file)
@@ -214,13 +214,14 @@ void PartSet_Module::onMousePressed(QMouseEvent* theEvent)
 {
   PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(
                                        myWorkshop->operationMgr()->currentOperation());
-  if (aPreviewOp) {
+  Handle(V3d_View) aView = myWorkshop->viewer()->activeView();
+  if (aPreviewOp && (!aView.IsNull())) {
     XGUI_Selection* aSelection = myWorkshop->selector()->selection();
     // Initialise operation with preliminary selection
     std::list<ModuleBase_ViewerPrs> aSelected = aSelection->getSelected();
     std::list<ModuleBase_ViewerPrs> aHighlighted = aSelection->getHighlighted();
 
-    aPreviewOp->mousePressed(theEvent, myWorkshop->viewer()->activeView(), aSelected, aHighlighted);
+    aPreviewOp->mousePressed(theEvent, aView, aSelected, aHighlighted);
   }
 }
 
@@ -228,13 +229,14 @@ void PartSet_Module::onMouseReleased(QMouseEvent* theEvent)
 {
   PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(
                                        myWorkshop->operationMgr()->currentOperation());
-  if (aPreviewOp) {
+  Handle(V3d_View) aView = myWorkshop->viewer()->activeView();
+  if (aPreviewOp && (!aView.IsNull())) {
     XGUI_Selection* aSelection = myWorkshop->selector()->selection();
     // Initialise operation with preliminary selection
     std::list<ModuleBase_ViewerPrs> aSelected = aSelection->getSelected();
     std::list<ModuleBase_ViewerPrs> aHighlighted = aSelection->getHighlighted();
 
-    aPreviewOp->mouseReleased(theEvent, myWorkshop->viewer()->activeView(), aSelected, aHighlighted);
+    aPreviewOp->mouseReleased(theEvent, aView, aSelected, aHighlighted);
   }
 }
 
@@ -242,8 +244,9 @@ void PartSet_Module::onMouseMoved(QMouseEvent* theEvent)
 {
   PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(
                                        myWorkshop->operationMgr()->currentOperation());
-  if (aPreviewOp)
-    aPreviewOp->mouseMoved(theEvent, myWorkshop->viewer()->activeView());
+  Handle(V3d_View) aView = myWorkshop->viewer()->activeView();
+  if (aPreviewOp && (!aView.IsNull()))
+    aPreviewOp->mouseMoved(theEvent, aView);
 }
 
 void PartSet_Module::onKeyRelease(QKeyEvent* theEvent)
@@ -259,14 +262,13 @@ void PartSet_Module::onMouseDoubleClick(QMouseEvent* theEvent)
 {
   PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(
                                        myWorkshop->operationMgr()->currentOperation());
-  if (aPreviewOp)
-  {
+  Handle(V3d_View) aView = myWorkshop->viewer()->activeView();
+  if (aPreviewOp && (!aView.IsNull())) {
     XGUI_Selection* aSelection = myWorkshop->selector()->selection();
     // Initialise operation with preliminary selection
     std::list<ModuleBase_ViewerPrs> aSelected = aSelection->getSelected();
     std::list<ModuleBase_ViewerPrs> aHighlighted = aSelection->getHighlighted();
-    aPreviewOp->mouseDoubleClick(theEvent, myWorkshop->viewer()->activeView(), aSelected,
-                                 aHighlighted);
+    aPreviewOp->mouseDoubleClick(theEvent, aView, aSelected, aHighlighted);
   }
 }
 
index ff33f60eb7b4c9a48e0539c9890f1d6b8b1a51b5..549b3e449c495895978eb5bc9c694f21d10fc1a6 100644 (file)
@@ -197,7 +197,9 @@ QMdiSubWindow* XGUI_Viewer::createView(V3d_TypeOfView theType)
 
 XGUI_ViewWindow* XGUI_Viewer::activeViewWindow() const
 {
-  return dynamic_cast<XGUI_ViewWindow*>(myActiveView->widget());
+  if (myActiveView)
+    return dynamic_cast<XGUI_ViewWindow*>(myActiveView->widget());
+  return 0;
 }
 
 void XGUI_Viewer::getSelectedObjects(AIS_ListOfInteractive& theList)
index 19453efdb3a4719691ba02a5952c86c9a4cf14fe..65c21fc5853e4efd9e6bfbc7ddc30040a1109f69 100644 (file)
@@ -37,7 +37,9 @@ Handle(V3d_View) XGUI_ViewerProxy::activeView() const
     return myWorkshop->salomeConnector()->viewer()->activeView();
   } else {
     XGUI_Viewer* aViewer = myWorkshop->mainWindow()->viewer();
-    return aViewer->activeViewWindow()->viewPort()->getView();
+    return (aViewer->activeViewWindow())?
+      aViewer->activeViewWindow()->viewPort()->getView():
+      Handle(V3d_View)();
   }
 }
  
@@ -58,7 +60,8 @@ void XGUI_ViewerProxy::fitAll()
   }
   else {
     XGUI_Viewer* aViewer = myWorkshop->mainWindow()->viewer();
-    aViewer->activeViewWindow()->viewPort()->fitAll();
+    if (aViewer->activeViewWindow())
+      aViewer->activeViewWindow()->viewPort()->fitAll();
   }
 }