From 579de874d9174e108a5bab6cfe7a7223d5f3a35a Mon Sep 17 00:00:00 2001 From: isn Date: Fri, 5 Apr 2019 19:24:05 +0300 Subject: [PATCH] crash on exit (hydro module -> close) --- src/HYDROGUI/HYDROGUI_Overview.cxx | 24 ++++++++++++++++++++++-- src/HYDROGUI/HYDROGUI_Overview.h | 1 + 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/HYDROGUI/HYDROGUI_Overview.cxx b/src/HYDROGUI/HYDROGUI_Overview.cxx index 15377580..4b15a6b1 100644 --- a/src/HYDROGUI/HYDROGUI_Overview.cxx +++ b/src/HYDROGUI/HYDROGUI_Overview.cxx @@ -309,7 +309,12 @@ QImage HYDROGUI_Overview::dump() const OCCViewer_ViewPort3d* HYDROGUI_Overview::getViewPort( bool isMain ) const { - return isMain ? myMainView->getViewPort() : myViewPort; + if ( isMain) + { + myMainView ? myMainView->getViewPort() : NULL; + } + else + return myViewPort; } void HYDROGUI_Overview::setMainView( OCCViewer_ViewFrame* theMainView ) @@ -324,7 +329,9 @@ void HYDROGUI_Overview::setMainView( OCCViewer_ViewFrame* theMainView ) connect( aMainView->getViewPort(), SIGNAL( vpResizeEvent( QResizeEvent* ) ), this, SLOT( OnResizeEvent( QResizeEvent* ) ) ); connect( aMainView->getViewPort(), SIGNAL( vpTransformed( OCCViewer_ViewPort* ) ), - this, SLOT( OnTransformation() ) ); + this, SLOT( OnTransformation() ) ); + + connect( myMainView, SIGNAL(destroyed()), this, SLOT( onMainViewDestr() ) ); if( !myViewPort ) { @@ -477,6 +484,19 @@ void HYDROGUI_Overview::OnResizeEvent( QResizeEvent* ) myBand->update( true ); } + +void HYDROGUI_Overview::onMainViewDestr() +{ + myMainView = NULL; + if (myViewPort == NULL) + return; + Handle(V3d_View) ov = myViewPort->getView(); + ov->View()->Deactivate(); + delete myViewPort; + myViewPort = NULL; +} + + void HYDROGUI_Overview::CustomFitSelection() const { OCCViewer_ViewPort3d* main = getViewPort( true ); diff --git a/src/HYDROGUI/HYDROGUI_Overview.h b/src/HYDROGUI/HYDROGUI_Overview.h index 6ab94a4b..36a1a2d7 100644 --- a/src/HYDROGUI/HYDROGUI_Overview.h +++ b/src/HYDROGUI/HYDROGUI_Overview.h @@ -57,6 +57,7 @@ private slots: void OnTransformation(); void OnMouseEvent( QMouseEvent* ); void OnResizeEvent( QResizeEvent* ); + void onMainViewDestr(); private: QGridLayout* myLayout; -- 2.39.2