]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
Some checks for correction SIGSEGV after closing animation dialog.
authormkr <mkr@opencascade.com>
Thu, 7 Dec 2006 14:29:59 +0000 (14:29 +0000)
committermkr <mkr@opencascade.com>
Thu, 7 Dec 2006 14:29:59 +0000 (14:29 +0000)
src/VISUGUI/VisuGUI_TimeAnimation.cxx
src/VISUGUI/VisuGUI_TimeAnimation.h
src/VISU_I/VISU_TimeAnimation.cxx

index 5f3ea9e9fa6923c864e1c2bbd00b241abb58b864..60db3ea32d26f81215842022ce13cd2b39ce2d8a 100644 (file)
@@ -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<SVTK_ViewWindow>(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<SVTK_ViewWindow>(myModule)->Repaint();
+    if ( VISU::GetActiveViewWindow<SVTK_ViewWindow>(myModule) )
+      VISU::GetActiveViewWindow<SVTK_ViewWindow>(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();
       }
index a4005098a6b5580524a7c3cf0c2190aba8c7d351..f717b3f68c7550edb66c9a037e8a3ea233328c9f 100644 (file)
@@ -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;
index e65ade37526dd294ef89fae017fa078f2ce49ab0..205e9fea5f08505560e7e3a87b486ca1ef7a13e1 100644 (file)
@@ -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<int>&
   while (myIsActive) {
     ProcessVoidEvent(new TVoidMemFun2ArgEvent<VISU_TimeAnimation,long,double>(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<int>&
     ProcessVoidEvent(new TVoidMemFun1ArgEvent<SVTK_ViewWindow,bool>(myView,
                                                                    &SVTK_ViewWindow::Repaint,
                                                                    repainArg));
+    }
 
     k = 1;
     if (myProportional) {
@@ -1119,6 +1122,7 @@ void VISU_TimeAnimation::succcessiveAnimation( bool& theIsDumping, QValueList<in
        ProcessVoidEvent(new TVoidMemFun2ArgEvent<VISU_TimeAnimation,long,double>(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<in
        ProcessVoidEvent(new TVoidMemFun1ArgEvent<SVTK_ViewWindow,bool>(myView,
                                                                        &SVTK_ViewWindow::Repaint,
                                                                        repainArg));
+       }
 
        k = 1;
        if (myProportional) {