Salome HOME
refs #1393: patch for crash
authorasl <asl@opencascade.com>
Fri, 10 Nov 2017 10:01:30 +0000 (13:01 +0300)
committerasl <asl@opencascade.com>
Fri, 10 Nov 2017 10:01:30 +0000 (13:01 +0300)
src/HYDROGUI/HYDROGUI_Overview.cxx

index 3f34cf1775ec889e2cabda75bf3e832383d21e4f..7a6c18976b5204579269d04823784ddec152f60c 100644 (file)
@@ -315,14 +315,18 @@ void HYDROGUI_Overview::setMainView( OCCViewer_ViewFrame* theMainView )
   if( !myViewPort )
   {
     myViewPort = new OCCViewer_ViewPort3d( this, myMainView->getViewPort()->getViewer(), V3d_ORTHOGRAPHIC );
-    myViewPort->setBackgroundColor( myMainView->getViewPort()->backgroundColor() );
 
-    connect( myViewPort, SIGNAL( vpMouseEvent( QMouseEvent* ) ), 
-            this,       SLOT( OnMouseEvent( QMouseEvent* ) ) );
-    connect( myViewPort, SIGNAL( vpResizeEvent( QResizeEvent* ) ),
-            this,       SLOT( OnResizeEvent( QResizeEvent* ) ) );
+    if( myViewPort )
+    {
+      myViewPort->setBackgroundColor( myMainView->getViewPort()->backgroundColor() );
+
+      connect( myViewPort, SIGNAL( vpMouseEvent( QMouseEvent* ) ), 
+              this,       SLOT( OnMouseEvent( QMouseEvent* ) ) );
+      connect( myViewPort, SIGNAL( vpResizeEvent( QResizeEvent* ) ),
+              this,       SLOT( OnResizeEvent( QResizeEvent* ) ) );
 
-    myLayout->addWidget( myViewPort, 0, 0 );
+      myLayout->addWidget( myViewPort, 0, 0 );
+    }
   }
 
 #if defined(TEST_MODE) || defined(_DEBUG)
@@ -343,6 +347,9 @@ void HYDROGUI_Overview::setMainView( OCCViewer_ViewFrame* theMainView )
 
 void HYDROGUI_Overview::setTopView()
 {
+  if( !myViewPort )
+    return;
+
   Handle(V3d_View) aView3d = myViewPort->getView();
   if( !aView3d.IsNull() )
     aView3d->SetProj( V3d_Zpos );
@@ -361,7 +368,7 @@ void HYDROGUI_Overview::setTopView()
 
 void HYDROGUI_Overview::OnTransformationAfterOp( OCCViewer_ViewWindow::OperationType theOp )
 {
-  if( theOp>=OCCViewer_ViewWindow::WINDOWFIT )
+  if( myViewPort && theOp>=OCCViewer_ViewWindow::WINDOWFIT )
   {
     myViewPort->fitAll();
   }
@@ -376,6 +383,9 @@ void HYDROGUI_Overview::OnTransformation()
 
 QPoint HYDROGUI_Overview::fromMain( int xp, int yp ) const
 {
+  if( !myMainView || !myViewPort )
+    return QPoint();
+
   const double EPS = 1E-2;
 
   Handle(V3d_View) aMain = myMainView->getViewPort()->getView();