Commit 2b9e0d0f authored by Utkarsh Ayachit's avatar Utkarsh Ayachit Committed by Kitware Robot
Browse files

Merge topic 'fix_vtklegacy_loading_crash'

7d211045 Fix crash on loading VTK legacy file with no timesteps.
parents e1e2f8be 7d211045
...@@ -74,21 +74,25 @@ void pqDataTimeStepBehavior::onReaderCreated(pqPipelineSource* reader) ...@@ -74,21 +74,25 @@ void pqDataTimeStepBehavior::onReaderCreated(pqPipelineSource* reader)
{ {
vtkSMPropertyHelper helper(readerProxy, "TimestepValues"); vtkSMPropertyHelper helper(readerProxy, "TimestepValues");
unsigned int num_timesteps = helper.GetNumberOfElements(); unsigned int num_timesteps = helper.GetNumberOfElements();
std::vector<double> timesteps = helper.GetDoubleArray(); if (num_timesteps > 0)
unsigned int newTimeStep = {
(defaultTimeStep == vtkPVGeneralSettings::DEFAULT_TIME_STEP_FIRST) ? 0 : std::vector<double> timesteps = helper.GetDoubleArray();
(num_timesteps - 1); unsigned int newTimeStep =
scene->setAnimationTime(timesteps[newTimeStep]); (defaultTimeStep == vtkPVGeneralSettings::DEFAULT_TIME_STEP_FIRST) ? 0 :
(num_timesteps - 1);
scene->setAnimationTime(timesteps[newTimeStep]);
}
} }
else if (readerProxy->GetProperty("TimeRange")) else if (readerProxy->GetProperty("TimeRange"))
{ {
vtkSMPropertyHelper helper(readerProxy, "TimeRange"); vtkSMPropertyHelper helper(readerProxy, "TimeRange");
std::vector<double> timeRange = helper.GetDoubleArray(); std::vector<double> timeRange = helper.GetDoubleArray();
double newTime = if (timeRange.size() > 0)
(defaultTimeStep == vtkPVGeneralSettings::DEFAULT_TIME_STEP_FIRST) ? {
timeRange[0] : timeRange[1]; double newTime =
scene->setAnimationTime(newTime); (defaultTimeStep == vtkPVGeneralSettings::DEFAULT_TIME_STEP_FIRST) ?
timeRange[0] : timeRange[1];
scene->setAnimationTime(newTime);
}
} }
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment