From 38c35f14edc698d65af03f7e157775b8b778937e Mon Sep 17 00:00:00 2001 From: asl Date: Fri, 9 Dec 2005 14:57:33 +0000 Subject: [PATCH] PAL8983 - crash if user closes study during animation is playing --- src/VISU_I/VISU_TimeAnimation.cxx | 22 +++++++++++++++++++++- src/VISU_I/VISU_TimeAnimation.h | 3 +++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/VISU_I/VISU_TimeAnimation.cxx b/src/VISU_I/VISU_TimeAnimation.cxx index 0c24e562..e9a04037 100644 --- a/src/VISU_I/VISU_TimeAnimation.cxx +++ b/src/VISU_I/VISU_TimeAnimation.cxx @@ -61,6 +61,7 @@ VISU_TimeAnimation::VISU_TimeAnimation (_PTR(Study) theStudy, VISU::View3D_i* pView = dynamic_cast(GetServant(theView3D).in()); SUIT_ViewWindow* aVW = pView->GetViewWindow(); myView = VISU::GetViewWindow(aVW); + connect( myView, SIGNAL( destroyed() ), this, SLOT( onViewDeleted() ) ); } myMaxVal = 0; @@ -117,6 +118,9 @@ void VISU_TimeAnimation::addField (SALOMEDS::SObject_ptr theField) //************************************************************************ void VISU_TimeAnimation::clearData(FieldData& theData) { + if( !myView ) + return; + theData.myTiming.clear(); vtkRenderer* aRen = myView->getRenderer(); if (!theData.myActors.empty()) { @@ -355,6 +359,9 @@ void VISU_TimeAnimation::startAnimation() { //************************************************************************ void VISU_TimeAnimation::nextFrame() { + if( !myView ) + return; + stopAnimation(); if (myFrame < (myFieldsLst[0].myNbFrames-1)) { int i; @@ -374,6 +381,8 @@ void VISU_TimeAnimation::nextFrame() { //************************************************************************ void VISU_TimeAnimation::prevFrame() { + if( !myView ) + return; stopAnimation(); if (myFrame > 0) { int i; @@ -393,6 +402,9 @@ void VISU_TimeAnimation::prevFrame() { //************************************************************************ void VISU_TimeAnimation::firstFrame() { + if( !myView ) + return; + stopAnimation(); int i; for (i = 0; i < getNbFields(); i++) @@ -412,6 +424,9 @@ void VISU_TimeAnimation::firstFrame() { //************************************************************************ void VISU_TimeAnimation::lastFrame() { + if( !myView ) + return; + stopAnimation(); int i; for (i = 0; i < getNbFields(); i++) @@ -431,7 +446,7 @@ void VISU_TimeAnimation::lastFrame() { //************************************************************************ // For Batchmode using void VISU_TimeAnimation::gotoFrame(CORBA::Long theFrame) { - if ((theFrame < 0) || (theFrame > (getNbFrames()-1))) + if ((theFrame < 0) || (theFrame > (getNbFrames()-1)) || !myView ) return; stopAnimation(); qApp->lock(); @@ -825,6 +840,11 @@ void VISU_TimeAnimation::restoreFromStudy(_PTR(SObject) theField) myAnimEntry = aStr.c_str(); } +void VISU_TimeAnimation::onViewDeleted() +{ + myView = 0; +} + //======================================================================== //======================================================================== diff --git a/src/VISU_I/VISU_TimeAnimation.h b/src/VISU_I/VISU_TimeAnimation.h index 26cc764c..59bf57cb 100644 --- a/src/VISU_I/VISU_TimeAnimation.h +++ b/src/VISU_I/VISU_TimeAnimation.h @@ -129,6 +129,9 @@ class VISU_TimeAnimation: public QObject, public QThread void run(); QString GenerateName(); + private slots: + void onViewDeleted(); + private: QString myLastError; -- 2.39.2