mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-26 23:20:29 -05:00
#14112 Contour map: guard remaining legend config dereferences
Guard the remaining unguarded legendConfig() uses so a null legend config cannot crash: both updateLegend() implementations (eclipse and statistics projections) now capture the pointer and return early when null, and the statistics view tree ordering skips a null legend config.
This commit is contained in:
1 parent
ea719c41b3
commit
85f5848bde
3 files changed
+16
-7
No files matched your search
@@ -112,6 +112,9 @@ RimRegularLegendConfig* RimEclipseContourMapProjection::legendConfig() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimEclipseContourMapProjection::updateLegend()
|
||||
{
|
||||
RimRegularLegendConfig* legend = legendConfig();
|
||||
if ( !legend ) return;
|
||||
|
||||
RimEclipseCellColors* cellColors = view()->cellResult();
|
||||
|
||||
auto [minValAllTimeSteps, maxValAllTimeSteps] = minmaxValuesAllTimeSteps();
|
||||
@@ -119,11 +122,11 @@ void RimEclipseContourMapProjection::updateLegend()
|
||||
double minVal = m_contourMapProjection ? m_contourMapProjection->minValue() : std::numeric_limits<double>::infinity();
|
||||
double maxVal = m_contourMapProjection ? m_contourMapProjection->maxValue() : -std::numeric_limits<double>::infinity();
|
||||
|
||||
legendConfig()->setAutomaticRanges( minValAllTimeSteps, maxValAllTimeSteps, minVal, maxVal );
|
||||
legend->setAutomaticRanges( minValAllTimeSteps, maxValAllTimeSteps, minVal, maxVal );
|
||||
|
||||
if ( isColumnResult() )
|
||||
{
|
||||
legendConfig()->setTitle( QString( "Map Projection\n%1" ).arg( m_resultAggregation().uiText() ) );
|
||||
legend->setTitle( QString( "Map Projection\n%1" ).arg( m_resultAggregation().uiText() ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -134,7 +137,7 @@ void RimEclipseContourMapProjection::updateLegend()
|
||||
}
|
||||
projectionLegendText += QString( "\nResult: %1" ).arg( cellColors->resultVariableUiShortName() );
|
||||
|
||||
legendConfig()->setTitle( projectionLegendText );
|
||||
legend->setTitle( projectionLegendText );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+6
-3
@@ -112,23 +112,26 @@ RimRegularLegendConfig* RimStatisticsContourMapProjection::legendConfig() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimStatisticsContourMapProjection::updateLegend()
|
||||
{
|
||||
RimRegularLegendConfig* legend = legendConfig();
|
||||
if ( !legend ) return;
|
||||
|
||||
auto [minValAllTimeSteps, maxValAllTimeSteps] = minmaxValuesAllTimeSteps();
|
||||
|
||||
double minVal = m_contourMapProjection ? m_contourMapProjection->minValue() : std::numeric_limits<double>::infinity();
|
||||
double maxVal = m_contourMapProjection ? m_contourMapProjection->maxValue() : -std::numeric_limits<double>::infinity();
|
||||
|
||||
legendConfig()->setAutomaticRanges( minValAllTimeSteps, maxValAllTimeSteps, minVal, maxVal );
|
||||
legend->setAutomaticRanges( minValAllTimeSteps, maxValAllTimeSteps, minVal, maxVal );
|
||||
|
||||
if ( statisticsContourMap()->isColumnResult() )
|
||||
{
|
||||
legendConfig()->setTitle( QString( "Map Projection\n%1" ).arg( resultVariableName() ) );
|
||||
legend->setTitle( QString( "Map Projection\n%1" ).arg( resultVariableName() ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
QString projectionLegendText = QString( "Map Projection\n%1" ).arg( resultAggregationText() );
|
||||
projectionLegendText += QString( "\nResult: %1" ).arg( resultVariableName() );
|
||||
|
||||
legendConfig()->setTitle( projectionLegendText );
|
||||
legend->setTitle( projectionLegendText );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -155,7 +155,10 @@ void RimStatisticsContourMapView::defineUiTreeOrdering( caf::PdmUiTreeOrdering&
|
||||
{
|
||||
uiTreeOrdering.add( m_overlayInfoConfig() );
|
||||
uiTreeOrdering.add( m_contourMapProjection );
|
||||
uiTreeOrdering.add( cellResult()->legendConfig() );
|
||||
if ( cellResult() && cellResult()->legendConfig() )
|
||||
{
|
||||
uiTreeOrdering.add( cellResult()->legendConfig() );
|
||||
}
|
||||
uiTreeOrdering.add( wellCollection() );
|
||||
uiTreeOrdering.add( faultCollection() );
|
||||
uiTreeOrdering.add( annotationCollection() );
|
||||
|
||||
Reference in new issue
Block a user