From 1d10274764d4097c6dd1d7fcaba36e347e11b580 Mon Sep 17 00:00:00 2001 From: apo Date: Tue, 19 Jun 2007 06:15:22 +0000 Subject: [PATCH] Fix for Bug IPAL16288 - 4.0 SIGSEGV during execution of the script, performing animation. --- src/VISU_I/VISU_TimeAnimation.cxx | 74 +++++++++++++++++-------------- 1 file changed, 40 insertions(+), 34 deletions(-) diff --git a/src/VISU_I/VISU_TimeAnimation.cxx b/src/VISU_I/VISU_TimeAnimation.cxx index 11ff50f3..5e1674bb 100644 --- a/src/VISU_I/VISU_TimeAnimation.cxx +++ b/src/VISU_I/VISU_TimeAnimation.cxx @@ -1058,26 +1058,27 @@ void VISU_TimeAnimation::parallelAnimation( bool& theIsDumping, QValueList& { 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 (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(aData.myActors[myFrame], @@ -1096,14 +1097,14 @@ void VISU_TimeAnimation::parallelAnimation( bool& theIsDumping, QValueList& 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& 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 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 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, QValueListIsActive()) + } // 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; -- 2.39.2