#14398 Guard against out of range time step in well allocation plot

This commit is contained in:
Magne Sjaastad authored and GitHub committed 2026-07-29 11:27:34 +02:00
1 parent 278621e97a
commit b1e741d5c3
3 files changed
+16 -4

No files matched your search

@@ -439,8 +439,13 @@ void RimWellAllocationPlot::updateFromWell()
QString wellStatusText = QString( "(%1)" ).arg( RimWellAllocationPlot::wellStatusTextForTimeStep( m_wellName, m_case, m_timeStep ) );
QString flowTypeText = m_flowDiagSolution() ? "Well Allocation" : "Well Flow";
setDescription( flowTypeText + ": " + m_wellName + " " + wellStatusText + ", " + m_case->timeStepStrings()[m_timeStep] + " (" +
m_case->caseUserDescription() + ")" );
// The stored time step can be out of range if the case has been replaced by a case with fewer time steps
const QStringList timeStepNames = m_case->timeStepStrings();
QString timeStepText;
if ( m_timeStep() >= 0 && m_timeStep() < timeStepNames.size() ) timeStepText = timeStepNames[m_timeStep];
setDescription( flowTypeText + ": " + m_wellName + " " + wellStatusText + ", " + timeStepText + " (" + m_case->caseUserDescription() + ")" );
/// Pie chart
@@ -465,7 +465,11 @@ QString RimGridCrossPlotDataSet::timeStepString() const
{
return "All Time Steps";
}
return m_case->timeStepStrings()[m_timeStep];
// The stored time step can be out of range if the data set has been switched to a case with fewer time steps
const QStringList timeStepNames = m_case->timeStepStrings();
if ( m_timeStep() >= 0 && m_timeStep() < timeStepNames.size() ) return timeStepNames[m_timeStep];
return "";
}
}
return "";
@@ -253,7 +253,10 @@ std::string RimGridStatisticsHistogramDataSource::name() const
if ( m_case() && m_property->hasDynamicResult() )
{
if ( m_timeStep == -1 ) return "All Time Steps";
return m_case->timeStepStrings()[m_timeStep];
// The stored time step can be out of range if the case has been replaced by a case with fewer time steps
const QStringList timeStepNames = m_case->timeStepStrings();
if ( m_timeStep() >= 0 && m_timeStep() < timeStepNames.size() ) return timeStepNames[m_timeStep];
}
return "";