From 6d8ee8d6852a69355e7fe8561f2a3122eff3e384 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Sat, 24 Oct 2026 13:18:25 +0200 Subject: [PATCH] Guard missing eclipse case data in viewer context menu Avoid null dereference of eclipseCase()/eclipseCaseData()/mainGrid() when building the IJK intersection context menu entries. Call stack: RimEclipseCase::eclipseCaseData() at RimEclipseCase.cpp:197 RiuViewerCommands::displayContextMenu(QMouseEvent*) at RiuViewerCommands.cpp:443 --- ApplicationLibCode/UserInterface/RiuViewerCommands.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ApplicationLibCode/UserInterface/RiuViewerCommands.cpp b/ApplicationLibCode/UserInterface/RiuViewerCommands.cpp index 47aeedc763..2c508bee4c 100644 --- a/ApplicationLibCode/UserInterface/RiuViewerCommands.cpp +++ b/ApplicationLibCode/UserInterface/RiuViewerCommands.cpp @@ -456,7 +456,8 @@ void RiuViewerCommands::displayContextMenu( QMouseEvent* event ) menuBuilder << "RicIntersectionBoxYSliceFeature"; menuBuilder << "RicIntersectionBoxZSliceFeature"; - if ( auto eclipseView = dynamic_cast( mainOrComparisonView ) ) + if ( auto eclipseView = dynamic_cast( mainOrComparisonView ); + eclipseView && eclipseView->eclipseCase() && eclipseView->eclipseCase()->eclipseCaseData() ) { // I/J/K intersections follow the main grid, so map the picked cell to the main grid const RigGridBase* grid = eclipseView->eclipseCase()->eclipseCaseData()->grid( m_currentGridIdx ); @@ -465,7 +466,7 @@ void RiuViewerCommands::displayContextMenu( QMouseEvent* event ) size_t mainGridCellIndex = grid->cell( m_currentCellIndex ).mainGridCellIndex(); size_t i, j, k; - if ( eclipseView->mainGrid()->ijkFromCellIndex( mainGridCellIndex, &i, &j, &k ) ) + if ( eclipseView->mainGrid() && eclipseView->mainGrid()->ijkFromCellIndex( mainGridCellIndex, &i, &j, &k ) ) { QVariantList iIntersectionList = { 0, static_cast( i ) }; QVariantList jIntersectionList = { 1, static_cast( j ) };