From be4caf97540c29a2eb81d58f1fa8d5069c5a310d Mon Sep 17 00:00:00 2001 From: san Date: Wed, 21 Dec 2011 13:50:45 +0000 Subject: [PATCH] Protection against occasional crashes in SUIT_ViewManager::closeAllViews() - using QObject::deleteLater() instead of operator delete. Protection in SVTK_Renderer destructor against unintentional updates of scene parameters during deletion. --- src/SUIT/SUIT_ViewManager.cxx | 5 +++-- src/SVTK/SVTK_Renderer.cxx | 9 +++++++-- src/SVTK/SVTK_Renderer.h | 1 + 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/SUIT/SUIT_ViewManager.cxx b/src/SUIT/SUIT_ViewManager.cxx index 4249fa872..dc4d518e2 100755 --- a/src/SUIT/SUIT_ViewManager.cxx +++ b/src/SUIT/SUIT_ViewManager.cxx @@ -267,7 +267,7 @@ void SUIT_ViewManager::closeView( SUIT_ViewWindow* theView ) removeView( view ); if ( view ) - delete view; + view->deleteLater(); } /*!Remove view window \a theView from view manager. @@ -340,7 +340,8 @@ void SUIT_ViewManager::closeAllViews() { for ( int i = 0; i < myViews.size(); i++ ){ if( !myViews[i].isNull() ) - delete myViews[i]; + myViews[i]->hide(); + myViews[i]->deleteLater(); } myViews.clear(); } diff --git a/src/SVTK/SVTK_Renderer.cxx b/src/SVTK/SVTK_Renderer.cxx index cab5ca695..37e1eaf65 100644 --- a/src/SVTK/SVTK_Renderer.cxx +++ b/src/SVTK/SVTK_Renderer.cxx @@ -76,7 +76,8 @@ SVTK_Renderer myCubeAxes(SVTK_CubeAxesActor2D::New()), myTrihedron(SVTK_Trihedron::New()), myTrihedronSize(105), - myIsTrihedronRelative(true) + myIsTrihedronRelative(true), + myIsDestroying(false) { myDevice->Delete(); myTransform->Delete(); @@ -157,6 +158,8 @@ SVTK_Renderer SVTK_Renderer ::~SVTK_Renderer() { + myIsDestroying = true; + vtkActorCollection* anActors = GetDevice()->GetActors(); vtkActorCollection* anActors2 = vtkActorCollection::New(); @@ -276,7 +279,9 @@ SVTK_Renderer anActor->SetHighlightProperty(NULL); anActor->RemoveFromRender(GetDevice()); - AdjustActors(); + + if ( !myIsDestroying ) + AdjustActors(); } } diff --git a/src/SVTK/SVTK_Renderer.h b/src/SVTK/SVTK_Renderer.h index 5c24cefa1..02ba4ab3f 100644 --- a/src/SVTK/SVTK_Renderer.h +++ b/src/SVTK/SVTK_Renderer.h @@ -250,6 +250,7 @@ class SVTK_EXPORT SVTK_Renderer : public vtkObject vtkFloatingPointType myTrihedronSize; bool myIsTrihedronRelative; vtkFloatingPointType myBndBox[6]; + bool myIsDestroying; }; #ifdef WIN32 -- 2.39.2