From: mkr Date: Thu, 7 Dec 2006 14:29:59 +0000 (+0000) Subject: Some checks for correction SIGSEGV after closing animation dialog. X-Git-Tag: V3_2_4~11 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=300701e02271ffe473c91b09c27f78484cbeb3c4;p=modules%2Fvisu.git Some checks for correction SIGSEGV after closing animation dialog. --- diff --git a/src/VISUGUI/VisuGUI_TimeAnimation.cxx b/src/VISUGUI/VisuGUI_TimeAnimation.cxx index 5f3ea9e9..60db3ea3 100644 --- a/src/VISUGUI/VisuGUI_TimeAnimation.cxx +++ b/src/VISUGUI/VisuGUI_TimeAnimation.cxx @@ -1072,6 +1072,7 @@ VisuGUI_TimeAnimationDlg::VisuGUI_TimeAnimationDlg (VisuGUI* theModule, _PTR(Stu setCaption(tr("SUCCESSIVE_ANIMATION")); setSizeGripEnabled( TRUE ); isClosing = false; + myCloseBtnClicked = false; myAnimator = new VISU_TimeAnimation (theStudy); myAnimator->setViewer(VISU::GetActiveViewWindow(theModule)); @@ -1287,7 +1288,7 @@ VisuGUI_TimeAnimationDlg::VisuGUI_TimeAnimationDlg (VisuGUI* theModule, _PTR(Stu aBtnLayout->addStretch(); QPushButton* aCloseBtn = new QPushButton(tr("BUT_CLOSE"), aBtnBox); - connect(aCloseBtn, SIGNAL(clicked()), this, SLOT(close())); + connect(aCloseBtn, SIGNAL(clicked()), this, SLOT(onClose())); QPushButton* aHelpBtn = new QPushButton(tr("BUT_HELP"), aBtnBox); connect(aHelpBtn, SIGNAL(clicked()), this, SLOT(onHelp())); @@ -1309,7 +1310,8 @@ VisuGUI_TimeAnimationDlg::~VisuGUI_TimeAnimationDlg() if(myAnimator != NULL){ delete myAnimator; myAnimator = NULL; - VISU::GetActiveViewWindow(myModule)->Repaint(); + if ( VISU::GetActiveViewWindow(myModule) ) + VISU::GetActiveViewWindow(myModule)->Repaint(); } } @@ -1432,6 +1434,12 @@ void VisuGUI_TimeAnimationDlg::reject() QDialog::reject(); } +void VisuGUI_TimeAnimationDlg::onClose() +{ + myCloseBtnClicked = true; + close(); +} + //------------------------------------------------------------------------ void VisuGUI_TimeAnimationDlg::closeEvent (QCloseEvent* theEvent) { @@ -1444,8 +1452,8 @@ void VisuGUI_TimeAnimationDlg::closeEvent (QCloseEvent* theEvent) // * Destroing data in myAnimator before study closed. // * It needed for correcting destroing of myAnimator, which // * depend from SVTK_RenderWindowInteractor() e.t.c. - if(theEvent->type() == QEvent::Close){ - for (int i = 0; i < myAnimator->getNbFields(); i++) + if(theEvent->type() == QEvent::Close && !myCloseBtnClicked){ + for (int i = 0; (myAnimator != NULL) && (i < myAnimator->getNbFields()); i++) myAnimator->clearData(myAnimator->getFieldData(i)); myAnimator->clearFieldData(); } diff --git a/src/VISUGUI/VisuGUI_TimeAnimation.h b/src/VISUGUI/VisuGUI_TimeAnimation.h index a4005098..f717b3f6 100644 --- a/src/VISUGUI/VisuGUI_TimeAnimation.h +++ b/src/VISUGUI/VisuGUI_TimeAnimation.h @@ -157,7 +157,7 @@ class VisuGUI_TimeAnimationDlg: public QDialog virtual void keyPressEvent(QKeyEvent* theEvent); virtual void reject(); void stopAnimation(); - + private slots: void onTypeChange(int index); void onPlayPressed(); @@ -181,6 +181,7 @@ class VisuGUI_TimeAnimationDlg: public QDialog void onPicsFormatChanged(); /*!Sets path for myAnimator (dumpTo(...)), from myPathEdit.*/ void onPathChanged(); + void onClose(); private: QSlider* mySlider; @@ -201,6 +202,7 @@ class VisuGUI_TimeAnimationDlg: public QDialog QComboBox* myPicsFormat; QLineEdit* myPathEdit; bool isClosing; + bool myCloseBtnClicked; QCloseEvent* myEvent; QCheckBox* mySaveAVICheck; diff --git a/src/VISU_I/VISU_TimeAnimation.cxx b/src/VISU_I/VISU_TimeAnimation.cxx index e65ade37..205e9fea 100644 --- a/src/VISU_I/VISU_TimeAnimation.cxx +++ b/src/VISU_I/VISU_TimeAnimation.cxx @@ -123,7 +123,7 @@ VISU_TimeAnimation::~VISU_TimeAnimation() for (int i = 0; i < getNbFields(); i++) { clearData(myFieldsLst[i]); } - + clearFieldData(); /* Terminates the execution of the thread. * The thread may or may not be terminated immediately, * depending on the operating system's scheduling policies. @@ -590,6 +590,7 @@ void VISU_TimeAnimation::clearView() void VISU_TimeAnimation::_visibilityOff(int num_field, int num_frame) { if ( num_field < 0 || num_frame < 0 ) return; FieldData& aData = myFieldsLst[num_field]; + if ( aData.myActors.empty() ) return; VISU_Actor* aActor = aData.myActors[num_frame]; if (! myCleaningMemoryAtEachFrame) { // @@ -1016,6 +1017,7 @@ void VISU_TimeAnimation::parallelAnimation( bool& theIsDumping, QValueList& while (myIsActive) { ProcessVoidEvent(new TVoidMemFun2ArgEvent(this, &VISU_TimeAnimation::_emitFrameChanged, myFrame, myFieldsLst[0].myTiming[myFrame])); + if (myIsActive) { if(!(myFieldsLst[0].myField)) break; for (int i = 0; i < getNbFields(); i++) { @@ -1036,6 +1038,7 @@ void VISU_TimeAnimation::parallelAnimation( bool& theIsDumping, QValueList& ProcessVoidEvent(new TVoidMemFun1ArgEvent(myView, &SVTK_ViewWindow::Repaint, repainArg)); + } k = 1; if (myProportional) { @@ -1119,6 +1122,7 @@ void VISU_TimeAnimation::succcessiveAnimation( bool& theIsDumping, QValueList(this, &VISU_TimeAnimation::_emitFrameChanged, myFrame, myFieldsLst[aFieldId].myTiming[aFrame])); + if (myIsActive) { if (aFrame > 0) { if (aData.myActors[aFrame-1] != 0) visibilityOff(aFieldId, aFrame-1); @@ -1141,6 +1145,7 @@ void VISU_TimeAnimation::succcessiveAnimation( bool& theIsDumping, QValueList(myView, &SVTK_ViewWindow::Repaint, repainArg)); + } k = 1; if (myProportional) {