From 8858d185bd356881614b5ee5730eac0723a0b5ea Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 8 Jun 2026 14:59:37 +0200 Subject: [PATCH] #14007 Contour Map: reset projection for all result types on case reload Reloading an Eclipse grid file destroys and recreates RigEclipseCaseData and its RigCaseCellResultsData. The contour map projection caches raw pointers to this case data in updateGridInformation() and only refreshes them when the projection is rebuilt. Previously the projection was reset on reload only when a GENERATED result was selected, so for any other result type the next scheduled redraw dereferenced the freed RigCaseCellResultsData in generateResults, crashing in hasResultEntry. Reset the grid mapping for all contour map views on reload so fresh case data pointers are captured. --- .../ProjectDataModel/RimReloadCaseTools.cpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/ApplicationLibCode/ProjectDataModel/RimReloadCaseTools.cpp b/ApplicationLibCode/ProjectDataModel/RimReloadCaseTools.cpp index 169b0fd2a9..c141d0f2c4 100644 --- a/ApplicationLibCode/ProjectDataModel/RimReloadCaseTools.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimReloadCaseTools.cpp @@ -148,15 +148,13 @@ void RimReloadCaseTools::updateAll3dViews( RimEclipseCase* eclipseCase ) { CVF_ASSERT( contourMap ); - if ( contourMap->cellResult()->resultType() == RiaDefines::ResultCatType::GENERATED ) - { - // When a generated result is selected, the data might come from a calculation. Make sure that all - // computations are updated based on new data. - // See RimEclipseContourMapProjection::generateResults() - contourMap->contourMapProjection()->clearGeometry(); - if ( auto projection = dynamic_cast( contourMap->contourMapProjection() ) ) - projection->clearGridMappingAndRedraw(); - } + // Reloading the grid file destroys and recreates RigEclipseCaseData, including the RigCaseCellResultsData + // that the contour map projection caches by raw pointer. The cached grid mapping and result data are only + // refreshed when the projection is rebuilt, so reset it here to avoid dereferencing the freed case data on + // the next redraw. See RimEclipseContourMapProjection::updateGridInformation() and generateResults(). + contourMap->contourMapProjection()->clearGeometry(); + if ( auto projection = dynamic_cast( contourMap->contourMapProjection() ) ) + projection->clearGridMappingAndRedraw(); contourMap->loadDataAndUpdate(); contourMap->updateGridBoxData();