From 135d8a8ae8fe36c32c1a1b8b40841441e872a95a Mon Sep 17 00:00:00 2001 From: akl Date: Mon, 22 Dec 2008 12:16:47 +0000 Subject: [PATCH] Fix of bug IPAL18279: 'SIGSEGV after closing study with opened "Animation" dlg'. --- src/VISU_I/VISU_TimeAnimation.cxx | 36 ++++++++++++++++--------------- src/VISU_I/VISU_TimeAnimation.h | 4 ++-- 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/src/VISU_I/VISU_TimeAnimation.cxx b/src/VISU_I/VISU_TimeAnimation.cxx index fb816303..ed79070d 100644 --- a/src/VISU_I/VISU_TimeAnimation.cxx +++ b/src/VISU_I/VISU_TimeAnimation.cxx @@ -188,8 +188,7 @@ VISU_TimeAnimation::VISU_TimeAnimation (_PTR(Study) theStudy, if (!CORBA::is_nil(theView3D)) { VISU::View3D_i* pView = dynamic_cast(GetServant(theView3D).in()); SUIT_ViewWindow* aVW = pView->GetViewWindow(); - myView = dynamic_cast(aVW); - connect( myView, SIGNAL( destroyed() ), this, SLOT( onViewDeleted() ) ); + setViewer( dynamic_cast(aVW) ); } myAnimationMode = VISU::Animation::PARALLEL; @@ -211,13 +210,7 @@ VISU_TimeAnimation::VISU_TimeAnimation (_PTR(Study) theStudy, //------------------------------------------------------------------------ VISU_TimeAnimation::~VISU_TimeAnimation() { - if (!myView) { - MESSAGE("Viewer is not defined for animation"); - return; - } - if (QThread::isRunning() && !QThread::isFinished()) { - //myExecutionState->SetActive(false); stopAnimation(); QThread::wait(500); if (QThread::isRunning() && !QThread::isFinished()) { @@ -225,7 +218,7 @@ VISU_TimeAnimation::~VISU_TimeAnimation() } } - for (int i = 0; i < getNbFields(); i++) { + for (int i = 0; i < getNbFields() && myView; i++) { clearData(myFieldsLst[i]); } clearFieldData(); @@ -254,6 +247,12 @@ VISU_TimeAnimation::~VISU_TimeAnimation() } +//------------------------------------------------------------------------ +void VISU_TimeAnimation::_connectView() +{ + connect( myView, SIGNAL( destroyed() ), this, SLOT( onViewDeleted() ) ); +} + //------------------------------------------------------------------------ bool VISU_TimeAnimation::addField (_PTR(SObject) theField) { @@ -748,6 +747,10 @@ void VISU_TimeAnimation::clearView() //------------------------------------------------------------------------ void VISU_TimeAnimation::_visibilityOff(int num_field, int num_frame) { + if (!myView) { + MESSAGE("Viewer is not defined for animation"); + return; + } if ( num_field < 0 || num_frame < 0 ) return; FieldData& aData = myFieldsLst[num_field]; if ( aData.myActors.empty() ) return; @@ -803,12 +806,6 @@ void VISU_TimeAnimation::startAnimation() (this,&VISU_TimeAnimation::_startAnimation)); } -//------------------------------------------------------------------------ -CORBA::Boolean VISU_TimeAnimation::isRunning() -{ - return myExecutionState->IsActive(); -} - //------------------------------------------------------------------------ void VISU_TimeAnimation::_nextFrame() { if (!myView) { @@ -1206,11 +1203,13 @@ void VISU_TimeAnimation::parallelAnimation( bool& theIsDumping, QList& theI if (aData.myActors[aData.myNbFrames-1] != 0) visibilityOff(i, aData.myNbFrames-1); } - if (aData.myActors[myFrame] != 0) { + if (aData.myActors[myFrame] != 0 && myView) { ProcessVoidEvent(new TVoidMemFunEvent(aData.myActors[myFrame], &VISU_Actor::VisibilityOn)); } } + if (!myView) + return; bool repainArg = false; ProcessVoidEvent(new TVoidMemFun1ArgEvent(myView, &SVTK_ViewWindow::Repaint, @@ -1318,11 +1317,13 @@ void VISU_TimeAnimation::successiveAnimation( bool& theIsDumping, QList& th if (aData.myActors[aData.myNbFrames-1] != 0) visibilityOff(aFieldId, aData.myNbFrames-1); } - if (aData.myActors[aFrame] != 0) { + if (aData.myActors[aFrame] != 0 && myView) { ProcessVoidEvent(new TVoidMemFunEvent(aData.myActors[aFrame], &VISU_Actor::VisibilityOn)); } + if (!myView) + return; bool repainArg = false; ProcessVoidEvent(new TVoidMemFun1ArgEvent(myView, &SVTK_ViewWindow::Repaint, @@ -1956,6 +1957,7 @@ void VISU_TimeAnimation::restoreFromStudy(_PTR(SObject) theField) void VISU_TimeAnimation::onViewDeleted() { myView = 0; + stopAnimation(); } void VISU_TimeAnimation::ApplyProperties(CORBA::Long theFieldNum, VISU::ColoredPrs3d_ptr thePrs) diff --git a/src/VISU_I/VISU_TimeAnimation.h b/src/VISU_I/VISU_TimeAnimation.h index 6938acaf..ee4c0601 100644 --- a/src/VISU_I/VISU_TimeAnimation.h +++ b/src/VISU_I/VISU_TimeAnimation.h @@ -68,6 +68,7 @@ class VISU_I_EXPORT VISU_TimeAnimation: public QThread protected: CORBA::Boolean _generateFrames(); + void _connectView(); void _visibilityOff(int num_field, int num_frame); void _clearView(); void _clearData(FieldData& theData); @@ -105,7 +106,7 @@ class VISU_I_EXPORT VISU_TimeAnimation: public QThread CORBA::Boolean generateFrames(); void generatePresentations(CORBA::Long theFieldNum); - void setViewer(SVTK_ViewWindow* theView) { myView = theView; } + void setViewer(SVTK_ViewWindow* theView) { myView = theView; _connectView(); } SVTK_ViewWindow* getViewer() { return myView; } void clearView(); void clearData(FieldData& theData); @@ -122,7 +123,6 @@ class VISU_I_EXPORT VISU_TimeAnimation: public QThread CORBA::Long getNbFields() { return myFieldsLst.size(); } CORBA::Long getNbFrames(); - CORBA::Boolean isRunning(); CORBA::Long getCurrentFrame() { return myFrame; } long getAbsoluteFrameNumber(std::pair theFieldTimeStamp); -- 2.39.2