#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.
This commit is contained in:
Magne Sjaastad committed 2026-06-08 15:52:49 +02:00
1 parent 0eb1c74a90
commit 8858d185bd
1 file changed
+7 -9
@@ -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<RimEclipseContourMapProjection*>( 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<RimEclipseContourMapProjection*>( contourMap->contourMapProjection() ) )
projection->clearGridMappingAndRedraw();
contourMap->loadDataAndUpdate();
contourMap->updateGridBoxData();