Fix crash when creating a view for a case whose grid file fails to load

RimEclipseView::onLoadDataAndUpdate() can be called again after a failed grid
load has cleared the view's eclipse case (RicNewViewFeature calls
loadDataAndUpdate once more after the view is added). On that second call the
open guard is skipped because eclipseCase() is already null, and the method then
dereferences eclipseCase() directly via dataFilterCollection(), crashing with a
null this pointer.

Return early when eclipseCase() is null after the open block, since there is
nothing to load without a case.
This commit is contained in:
Kristian Bendiksen committed 2026-06-08 15:35:31 +02:00
1 parent 5e2156fca1
commit 1376407486
1 file changed
+6
@@ -1255,6 +1255,12 @@ void RimEclipseView::onLoadDataAndUpdate()
}
}
// The reservoir case may be null here, either because none was assigned or because opening the grid file above
// failed and cleared it. This method can be invoked again after such a failure (e.g. RicNewViewFeature calls
// loadDataAndUpdate once more after the view is added), and the code below dereferences eclipseCase() directly
// (e.g. dataFilterCollection()). Without a case there is nothing to load, so bail out.
if ( !eclipseCase() ) return;
CVF_ASSERT( cellResult() != nullptr );
cellResult()->loadResult();