]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
0021769: EDF OCCT: Closing the OCC viewer leads to SIGSEGV (OCCT dev)
authorinv <inv@opencascade.com>
Thu, 4 Oct 2012 10:37:14 +0000 (10:37 +0000)
committerinv <inv@opencascade.com>
Thu, 4 Oct 2012 10:37:14 +0000 (10:37 +0000)
src/OCCViewer/OCCViewer_ViewModel.cxx
src/OCCViewer/OCCViewer_ViewModel.h
src/OCCViewer/OCCViewer_ViewPort3d.cxx
src/OCCViewer/OCCViewer_ViewPort3d.h

index a4f2bb86d3b361ce5b14b26e0d8ca79c05696dce..170b843e62c83c4abae3bd78e23cf0659d79740e 100755 (executable)
@@ -169,6 +169,9 @@ OCCViewer_Viewer::OCCViewer_Viewer( bool DisplayTrihedron)
 */
 OCCViewer_Viewer::~OCCViewer_Viewer() 
 {
+  myAISContext.Nullify();
+  myV3dViewer.Nullify();
+  myV3dCollector.Nullify();
 }
 
 /*!
@@ -240,6 +243,8 @@ SUIT_ViewWindow* OCCViewer_Viewer::createView( SUIT_Desktop* theDesktop )
   initView( vw );
   // set default background for view window
   vw->setBackground( background(0) ); // 0 means MAIN_VIEW (other views are not yet created here)
+  // connect signal from viewport
+  connect(view->getViewPort(), SIGNAL(vpClosed()), this, SLOT(onViewClosed()));
   return view;
 }
 
@@ -370,6 +375,17 @@ void OCCViewer_Viewer::onKeyPress(SUIT_ViewWindow* theWindow, QKeyEvent* theEven
   emit selectionChanged();
 }
 
+void OCCViewer_Viewer::onViewClosed()
+{
+  Standard_Integer aViewsNb = 0;
+  for ( myV3dViewer->InitActiveViews(); myV3dViewer->MoreActiveViews(); myV3dViewer->NextActiveViews())
+    ++aViewsNb;
+  if ( aViewsNb < 2 ) {
+    //clean up presentations before last view is closed
+    myAISContext->RemoveAll(Standard_False);
+  }
+}
+
 int OCCViewer_Viewer::getTopLayerId()
 {
 #if OCC_VERSION_LARGE > 0x06050200
index 90f128c23ab7a15b786cb5f3f333f92a9b17e3e1..46c1e47869abe9157c08d9619b49bccf03444ac1 100755 (executable)
@@ -163,6 +163,7 @@ protected slots:
   virtual void onMouseMove(SUIT_ViewWindow*, QMouseEvent*);
   virtual void onMouseRelease(SUIT_ViewWindow*, QMouseEvent*);
   virtual void onKeyPress(SUIT_ViewWindow*, QKeyEvent*);
+  virtual void onViewClosed();
 
   void onDumpView();
   void onChangeBackground();
index 26b0736b2f25f5daf4f93e5081b5bf94465baa1e..3dd08a8129a0ec1deda20976fe31eb4ffff6ebb0 100755 (executable)
@@ -92,6 +92,7 @@ OCCViewer_ViewPort3d::OCCViewer_ViewPort3d( QWidget* parent, const Handle( V3d_V
 */
 OCCViewer_ViewPort3d::~OCCViewer_ViewPort3d()
 {
+  emit vpClosed();
   Handle(V3d_View) aView = activeView();
   if (!aView.IsNull())
     aView->Remove();
index 17847bc3d776c5a876fff05d5e46ec87da565ca2..d8287297966393509e56378e23c63fce16853dcd 100755 (executable)
@@ -96,6 +96,7 @@ public:
 
 signals:
   void                  vpChangeBackground( const Qtx::BackgroundData& );
+  void                  vpClosed();
 
 public slots:
   virtual bool          synchronize( OCCViewer_ViewPort* );