]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
Fix for Bug IPAL16288 Before_Merging_With_Windows_20jun07
authorapo <apo@opencascade.com>
Tue, 19 Jun 2007 06:15:22 +0000 (06:15 +0000)
committerapo <apo@opencascade.com>
Tue, 19 Jun 2007 06:15:22 +0000 (06:15 +0000)
 - 4.0 SIGSEGV during execution of the script, performing animation.

src/VISU_I/VISU_TimeAnimation.cxx

index 11ff50f3ecbe1a8a9e1ac172bb2e66bc56217f33..5e1674bb5d7618b8504b85ac782b2ba860d0c3b3 100644 (file)
@@ -1058,26 +1058,27 @@ void VISU_TimeAnimation::parallelAnimation( bool& theIsDumping, QValueList<int>&
 {
   double k = 1;
   double aOneVal = 1;
-  if (myFieldsLst[0].myNbFrames > 2)
+  FieldData& aFirstFieldData = myFieldsLst[0];
+  if (aFirstFieldData.myNbFrames > 2)
     aOneVal = ( myTimeMax - myTimeMin ) / getNbFrames();
   int aNbFiles = 0;
 
-  bool hasHextFrame = true;
-  while (hasHextFrame && myExecutionState->IsActive()) {
+  bool aHasNextFrame = aFirstFieldData.myField && aFirstFieldData.myNbFrames > 0;
+  while (aHasNextFrame && myExecutionState->IsActive()) {
     ProcessVoidEvent(new TVoidMemFun2ArgEvent<VISU_TimeAnimation,long,double>
                      (this, &VISU_TimeAnimation::_emitFrameChanged,
-                      myFrame, myFieldsLst[0].myTiming[myFrame]));
+                      myFrame, aFirstFieldData.myTiming[myFrame]));
     if (myExecutionState->IsActive()) {
-      if (!(myFieldsLst[0].myField))
-        break;
       for (int i = 0; i < getNbFields(); i++) {
         FieldData& aData = myFieldsLst[i];
+       if (aData.myNbFrames == 0)
+         continue;
         if (myFrame > 0) {
           if (aData.myActors[myFrame-1] != 0)
             visibilityOff(i, myFrame-1);
         } else {
-          if (aData.myActors[aData.myNbFrames-1] != 0)
-            visibilityOff(i, aData.myNbFrames-1);
+         if (aData.myActors[aData.myNbFrames-1] != 0)
+           visibilityOff(i, aData.myNbFrames-1);
         }
         if (aData.myActors[myFrame] != 0) {
           ProcessVoidEvent(new TVoidMemFunEvent<VISU_Actor>(aData.myActors[myFrame],
@@ -1096,14 +1097,14 @@ void VISU_TimeAnimation::parallelAnimation( bool& theIsDumping, QValueList<int>&
       case 0:
         break;
       case 1:
-        if (myFieldsLst[0].myNbFrames > 2)
-          k = (myFieldsLst[0].myTiming[myFrame+1] -
-               myFieldsLst[0].myTiming[myFrame]) / aOneVal;
+        if (aFirstFieldData.myNbFrames > 2)
+          k = (aFirstFieldData.myTiming[myFrame+1] -
+               aFirstFieldData.myTiming[myFrame]) / aOneVal;
         break;
       default:
-        if (myFrame < (myFieldsLst[0].myNbFrames - 1))
-          k = (myFieldsLst[0].myTiming[myFrame+1] -
-               myFieldsLst[0].myTiming[myFrame]) / aOneVal;
+        if (myFrame < (aFirstFieldData.myNbFrames - 1))
+          k = (aFirstFieldData.myTiming[myFrame+1] -
+               aFirstFieldData.myTiming[myFrame]) / aOneVal;
       }
     }
     int delay = (int)(1000. * k / mySpeed);
@@ -1113,31 +1114,34 @@ void VISU_TimeAnimation::parallelAnimation( bool& theIsDumping, QValueList<int>&
       delay = 1;
     }
     msleep(delay);
-    if (!myExecutionState->IsActive()) return;
+    if (!myExecutionState->IsActive()) 
+      return;
 
     if (theIsDumping) {
       // We must unlock mutex for some time before grabbing to allow view updating
       msleep(delay);
-      if (!myExecutionState->IsActive()) return;
+      if (!myExecutionState->IsActive()) 
+       return;
 
-      if (!(myFieldsLst[0].myField)) // break, if field was deleted.
+      if (!(aFirstFieldData.myField)) // break, if field was deleted.
        break;
 
       saveImages( 0, aOneVal, aNbFiles, theIndexList );
     }
 
-    if (!myExecutionState->IsActive()) break;
+    if (!myExecutionState->IsActive()) 
+      break;
 
     myFrame++;
-    if (myFrame == myFieldsLst[0].myNbFrames) {
+    if (myFrame == aFirstFieldData.myNbFrames) {
       if (!myCycling) {
-        hasHextFrame = false;
+        aHasNextFrame = false;
        myFrame--;
       }
       else
        myFrame = 0;
     }
-  } // while (hasHextFrame && myExecutionState->IsActive())
+  } // while (aHasNextFrame && myExecutionState->IsActive())
 }
 
 //------------------------------------------------------------------------
@@ -1151,13 +1155,14 @@ void VISU_TimeAnimation::succcessiveAnimation( bool& theIsDumping, QValueList<in
 
   double k = 1;
   double aOneVal = 1;
-  if (myFieldsLst[0].myNbFrames > 2)
+  FieldData& aFirstFieldData = myFieldsLst[0];
+  if (aFirstFieldData.myNbFrames > 2)
     aOneVal = ( myTimeMax - myTimeMin ) / getNbFrames();
   int aNbFiles = 0;
   long aFrame = myFrame;
 
-  bool hasHextFrame = true;
-  while (hasHextFrame && myExecutionState->IsActive())
+  bool aHasNextFrame = true;
+  while (aHasNextFrame && myExecutionState->IsActive())
   {
     for (int aFieldId = 0;
          (aFieldId < getNbFields()) && (myFieldsLst[aFieldId].myField);
@@ -1204,14 +1209,14 @@ void VISU_TimeAnimation::succcessiveAnimation( bool& theIsDumping, QValueList<in
          case 0:
            break;
          case 1:
-           if (myFieldsLst[0].myNbFrames > 2)
-             k = (myFieldsLst[0].myTiming[aFrame+1] -
-                  myFieldsLst[0].myTiming[aFrame]) / aOneVal;
+           if (aFirstFieldData.myNbFrames > 2)
+             k = (aFirstFieldData.myTiming[aFrame+1] -
+                  aFirstFieldData.myTiming[aFrame]) / aOneVal;
            break;
          default:
-           if (aFrame < (myFieldsLst[0].myNbFrames - 1))
-             k = (myFieldsLst[0].myTiming[aFrame+1] -
-                  myFieldsLst[0].myTiming[aFrame]) / aOneVal;
+           if (aFrame < (aFirstFieldData.myNbFrames - 1))
+             k = (aFirstFieldData.myTiming[aFrame+1] -
+                  aFirstFieldData.myTiming[aFrame]) / aOneVal;
          }
        }
        int delay = (int)(1000. * k / mySpeed);
@@ -1238,14 +1243,14 @@ void VISU_TimeAnimation::succcessiveAnimation( bool& theIsDumping, QValueList<in
     } // for (int aFieldId = 0;
 
     if (!myCycling) {
-      hasHextFrame = false;
+      aHasNextFrame = false;
       myFrame--;
     }
     else {
       myFrame = 0;
       aFrame = myFrame;
     }
-  } // while (hasHextFrame && myExecutionState->IsActive())
+  } // while (aHasNextFrame && myExecutionState->IsActive())
 }
 
 //------------------------------------------------------------------------
@@ -1285,8 +1290,9 @@ void VISU_TimeAnimation::saveImages( int theFieldId,
       break;
     default:
       if (myProportional) {
-       double p = (myFieldsLst[0].myTiming[myFrame] -
-                   myFieldsLst[0].myTiming[myFrame-1]) / theOneVal;
+       FieldData& aFirstFieldData = myFieldsLst[0];
+       double p = (aFirstFieldData.myTiming[myFrame] -
+                   aFirstFieldData.myTiming[myFrame-1]) / theOneVal;
        myFileIndex += (long) (5*p);
       } else {
        myFileIndex += 5;