From e3143eb9497175a505b8559acb820af6fbf8e79a Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Sat, 18 Apr 2020 09:20:04 +0200 Subject: [PATCH] Grid cell time history curves : Guard null pointer access --- .../RimEclipseGeometrySelectionItem.cpp | 2 +- .../RimGridTimeHistoryCurve.cpp | 31 ++++++++++++------- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimEclipseGeometrySelectionItem.cpp b/ApplicationCode/ProjectDataModel/RimEclipseGeometrySelectionItem.cpp index f4922cdcbf..10390aa13f 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseGeometrySelectionItem.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseGeometrySelectionItem.cpp @@ -97,7 +97,7 @@ QString RimEclipseGeometrySelectionItem::geometrySelectionText() const } else { - text = "No case"; + return "No case"; } text += ", "; diff --git a/ApplicationCode/ProjectDataModel/RimGridTimeHistoryCurve.cpp b/ApplicationCode/ProjectDataModel/RimGridTimeHistoryCurve.cpp index 74147dbef8..ba28dea1c5 100644 --- a/ApplicationCode/ProjectDataModel/RimGridTimeHistoryCurve.cpp +++ b/ApplicationCode/ProjectDataModel/RimGridTimeHistoryCurve.cpp @@ -225,13 +225,16 @@ std::vector RimGridTimeHistoryCurve::yValues() const RigCaseCellResultsData* cellResultsData = m_eclipseResultDefinition->currentGridCellResults(); - std::vector timeStepDates = cellResultsData->timeStepDates(); + if ( cellResultsData ) + { + std::vector timeStepDates = cellResultsData->timeStepDates(); - values = RigTimeHistoryResultAccessor::timeHistoryValues( eclTopItem->eclipseCase()->eclipseCaseData(), - m_eclipseResultDefinition(), - gridIndex, - cellIndex, - timeStepDates.size() ); + values = RigTimeHistoryResultAccessor::timeHistoryValues( eclTopItem->eclipseCase()->eclipseCaseData(), + m_eclipseResultDefinition(), + gridIndex, + cellIndex, + timeStepDates.size() ); + } } if ( geoMechGeomSelectionItem() && geoMechGeomSelectionItem()->geoMechCase() ) @@ -464,11 +467,14 @@ std::vector RimGridTimeHistoryCurve::timeStepValues() const { RigCaseCellResultsData* cellResultsData = m_eclipseResultDefinition->currentGridCellResults(); - std::vector timeStepDates = cellResultsData->timeStepDates(); - - for ( QDateTime dt : timeStepDates ) + if ( cellResultsData ) { - dateTimes.push_back( dt.toTime_t() ); + std::vector timeStepDates = cellResultsData->timeStepDates(); + + for ( QDateTime dt : timeStepDates ) + { + dateTimes.push_back( dt.toTime_t() ); + } } } @@ -512,7 +518,10 @@ std::vector RimGridTimeHistoryCurve::daysSinceSimulationStart() const { RigCaseCellResultsData* cellResultsData = m_eclipseResultDefinition->currentGridCellResults(); - daysSinceSimulationStart = cellResultsData->daysSinceSimulationStart(); + if ( cellResultsData ) + { + daysSinceSimulationStart = cellResultsData->daysSinceSimulationStart(); + } } RimGeoMechGeometrySelectionItem* geoMechTopItem = geoMechGeomSelectionItem();