]> 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>
Mon, 22 Dec 2008 12:16:47 +0000 (12:16 +0000)
committerakl <akl@opencascade.com>
Mon, 22 Dec 2008 12:16:47 +0000 (12:16 +0000)
src/VISU_I/VISU_TimeAnimation.cxx
src/VISU_I/VISU_TimeAnimation.h

index fb81630304952936f686956db058fe78dd04cb1e..ed79070dc3580c22b1b58409ff4565a345be068a 100644 (file)
@@ -188,8 +188,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;
@@ -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<int>& 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<VISU_Actor>(aData.myActors[myFrame],
                                                             &VISU_Actor::VisibilityOn));
         }
       }
+      if (!myView)
+       return;
       bool repainArg = false;
       ProcessVoidEvent(new TVoidMemFun1ArgEvent<SVTK_ViewWindow,bool>(myView,
                                                                       &SVTK_ViewWindow::Repaint,
@@ -1318,11 +1317,13 @@ void VISU_TimeAnimation::successiveAnimation( bool& theIsDumping, QList<int>& 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<VISU_Actor>(aData.myActors[aFrame],
                                                               &VISU_Actor::VisibilityOn));
           }
 
+         if (!myView)
+           return;
           bool repainArg = false;
           ProcessVoidEvent(new TVoidMemFun1ArgEvent<SVTK_ViewWindow,bool>(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)
index 6938acafa8e66b48d148bf40697809302b9e9efd..ee4c0601ad0b4e35e57b9e17a00d45eb0aa52e7a 100644 (file)
@@ -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<int,long> theFieldTimeStamp);