From 1f10f7be3d13555d923fc8198fe8ff9c061482fb Mon Sep 17 00:00:00 2001 From: akl Date: Fri, 19 Dec 2008 09:37:36 +0000 Subject: [PATCH] Fix of bug IPAL18279: 'SIGSEGV after closing study with opened "Animation" dlg'. --- src/VISUGUI/VisuGUI_TimeAnimation.cxx | 2 +- src/VISU_I/VISU_TimeAnimation.cxx | 38 ++++++++++++++------------- src/VISU_I/VISU_TimeAnimation.h | 4 +-- 3 files changed, 23 insertions(+), 21 deletions(-) diff --git a/src/VISUGUI/VisuGUI_TimeAnimation.cxx b/src/VISUGUI/VisuGUI_TimeAnimation.cxx index 98ffb882..01fa92e5 100644 --- a/src/VISUGUI/VisuGUI_TimeAnimation.cxx +++ b/src/VISUGUI/VisuGUI_TimeAnimation.cxx @@ -1829,7 +1829,7 @@ void VisuGUI_TimeAnimationDlg::closeEvent (QCloseEvent* theEvent) //------------------------------------------------------------------------ void VisuGUI_TimeAnimationDlg::onWindowChanged (int index) { - if (myAnimator->isRunning()) return; + if (myAnimator->running()) return; myAnimator->gotoFrame(index); } diff --git a/src/VISU_I/VISU_TimeAnimation.cxx b/src/VISU_I/VISU_TimeAnimation.cxx index 71d47b37..453cbaa9 100644 --- a/src/VISU_I/VISU_TimeAnimation.cxx +++ b/src/VISU_I/VISU_TimeAnimation.cxx @@ -187,8 +187,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; @@ -210,13 +209,7 @@ VISU_TimeAnimation::VISU_TimeAnimation (_PTR(Study) theStudy, //------------------------------------------------------------------------ VISU_TimeAnimation::~VISU_TimeAnimation() { - if (!myView) { - MESSAGE("Viewer is not defined for animation"); - return; - } - if (QThread::running() && !QThread::finished()) { - //myExecutionState->SetActive(false); stopAnimation(); QThread::wait(500); if (QThread::running() && !QThread::finished()) { @@ -224,7 +217,7 @@ VISU_TimeAnimation::~VISU_TimeAnimation() } } - for (int i = 0; i < getNbFields(); i++) { + for (int i = 0; i < getNbFields() && myView; i++) { clearData(myFieldsLst[i]); } clearFieldData(); @@ -253,6 +246,12 @@ VISU_TimeAnimation::~VISU_TimeAnimation() } +//------------------------------------------------------------------------ +void VISU_TimeAnimation::_connectView() +{ + connect( myView, SIGNAL( destroyed() ), this, SLOT( onViewDeleted() ) ); +} + //------------------------------------------------------------------------ bool VISU_TimeAnimation::addField (_PTR(SObject) theField) { @@ -747,6 +746,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; @@ -802,12 +805,6 @@ void VISU_TimeAnimation::startAnimation() (this,&VISU_TimeAnimation::_startAnimation)); } -//------------------------------------------------------------------------ -CORBA::Boolean VISU_TimeAnimation::isRunning() -{ - return myExecutionState->IsActive(); -} - //------------------------------------------------------------------------ void VISU_TimeAnimation::_nextFrame() { if (!myView) { @@ -1190,11 +1187,13 @@ void VISU_TimeAnimation::parallelAnimation( bool& theIsDumping, QValueList& 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, @@ -1302,11 +1301,13 @@ void VISU_TimeAnimation::successiveAnimation( bool& theIsDumping, QValueList(aData.myActors[aFrame], &VISU_Actor::VisibilityOn)); } + if (!myView) + return; bool repainArg = false; ProcessVoidEvent(new TVoidMemFun1ArgEvent(myView, &SVTK_ViewWindow::Repaint, @@ -1940,6 +1941,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) @@ -2133,7 +2135,7 @@ CORBA::Long VISU_TimeAnimation_i::getNbFrames() CORBA::Boolean VISU_TimeAnimation_i::isRunning() { - return myAnim->isRunning(); + return myAnim->running(); } CORBA::Long VISU_TimeAnimation_i::getCurrentFrame() diff --git a/src/VISU_I/VISU_TimeAnimation.h b/src/VISU_I/VISU_TimeAnimation.h index ad882bae..506d94e6 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 QObject, 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 QObject, 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 QObject, 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