]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
Fix of bug IPAL18279: 'SIGSEGV after closing study with opened "Animation" dlg'.
authorakl <akl@opencascade.com>
Fri, 19 Dec 2008 09:37:36 +0000 (09:37 +0000)
committerakl <akl@opencascade.com>
Fri, 19 Dec 2008 09:37:36 +0000 (09:37 +0000)
src/VISUGUI/VisuGUI_TimeAnimation.cxx
src/VISU_I/VISU_TimeAnimation.cxx
src/VISU_I/VISU_TimeAnimation.h

index 98ffb882706ebbe1c1f39e08c6ef741055f91e6e..01fa92e5b3d98a95e6a0fbfb8a343874a07d684c 100644 (file)
@@ -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);
 }
 
index 71d47b373821403bac9bbdfa352ff49d9f4fe665..453cbaa9de45fe478f2664d6d427d20093d64edd 100644 (file)
@@ -187,8 +187,7 @@ VISU_TimeAnimation::VISU_TimeAnimation (_PTR(Study) theStudy,
   if (!CORBA::is_nil(theView3D)) {
     VISU::View3D_i* pView = dynamic_cast<VISU::View3D_i*>(GetServant(theView3D).in());
     SUIT_ViewWindow* aVW = pView->GetViewWindow();
-    myView = dynamic_cast<SVTK_ViewWindow*>(aVW);
-    connect( myView, SIGNAL( destroyed() ), this, SLOT( onViewDeleted() ) );
+    setViewer( dynamic_cast<SVTK_ViewWindow*>(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<int>&
          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<VISU_Actor>(aData.myActors[myFrame],
                                                             &VISU_Actor::VisibilityOn));
         }
       }
+      if (!myView)
+       return;
       bool repainArg = false;
       ProcessVoidEvent(new TVoidMemFun1ArgEvent<SVTK_ViewWindow,bool>(myView,
                                                                       &SVTK_ViewWindow::Repaint,
@@ -1302,11 +1301,13 @@ void VISU_TimeAnimation::successiveAnimation( bool& theIsDumping, QValueList<int
             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<VISU_Actor>(aData.myActors[aFrame],
                                                               &VISU_Actor::VisibilityOn));
           }
 
+         if (!myView)
+           return;
           bool repainArg = false;
           ProcessVoidEvent(new TVoidMemFun1ArgEvent<SVTK_ViewWindow,bool>(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()
index ad882bae1055d52a99879ebe56e2914f5265d66a..506d94e6a80053fde03b9057e62425f5a144333e 100644 (file)
@@ -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<int,long> theFieldTimeStamp);