Add nullptr guards to avoid crash when trying to use well allocation plot with an ensemble

This commit is contained in:
jonjenssen authored and Magne Sjaastad committed 2025-06-10 10:52:18 +02:00
1 parent d7d18ce9ab
commit 55a4bad0fb
6 files changed
+7 -6

No files matched your search

@@ -45,7 +45,7 @@ void RicSelectViewUI::setView( RimEclipseView* currentView )
{ {
m_currentView = currentView; m_currentView = currentView;
m_currentCase = m_currentView->firstAncestorOrThisOfTypeAsserted<RimEclipseResultCase>(); m_currentCase = m_currentView->firstAncestorOrThisOfType<RimEclipseResultCase>();
m_selectedView = m_currentView; m_selectedView = m_currentView;
} }
@@ -101,7 +101,7 @@ RimEclipseView* RicSelectOrCreateViewFeatureImpl::getDefaultSelectedView( RimEcl
dynamic_cast<RimEclipseView*>( caf::PdmReferenceHelper::objectFromReference( RimProject::current(), lastUsedViewRef ) ); dynamic_cast<RimEclipseView*>( caf::PdmReferenceHelper::objectFromReference( RimProject::current(), lastUsedViewRef ) );
if ( lastUsedView ) if ( lastUsedView )
{ {
RimEclipseResultCase* lastUsedViewResultCase = lastUsedView->firstAncestorOrThisOfTypeAsserted<RimEclipseResultCase>(); RimEclipseResultCase* lastUsedViewResultCase = lastUsedView->firstAncestorOrThisOfType<RimEclipseResultCase>();
if ( lastUsedViewResultCase == resultCase ) if ( lastUsedViewResultCase == resultCase )
{ {
@@ -114,7 +114,7 @@ RimEclipseView* RicSelectOrCreateViewFeatureImpl::getDefaultSelectedView( RimEcl
RimEclipseView* activeView = dynamic_cast<RimEclipseView*>( RiaApplication::instance()->activeReservoirView() ); RimEclipseView* activeView = dynamic_cast<RimEclipseView*>( RiaApplication::instance()->activeReservoirView() );
if ( activeView ) if ( activeView )
{ {
RimEclipseResultCase* activeViewResultCase = activeView->firstAncestorOrThisOfTypeAsserted<RimEclipseResultCase>(); RimEclipseResultCase* activeViewResultCase = activeView->firstAncestorOrThisOfType<RimEclipseResultCase>();
if ( activeViewResultCase == resultCase ) if ( activeViewResultCase == resultCase )
{ {
@@ -165,7 +165,7 @@ void RimWellAllocationOverTimePlot::setFromSimulationWell( RimSimWellInView* sim
// Use the active flow diagnostics solutions, or the first one as default // Use the active flow diagnostics solutions, or the first one as default
m_flowDiagSolution = eclView->cellResult()->flowDiagSolution(); m_flowDiagSolution = eclView->cellResult()->flowDiagSolution();
if ( !m_flowDiagSolution ) if ( ( m_flowDiagSolution == nullptr ) && ( m_case != nullptr ) )
{ {
m_flowDiagSolution = m_case->defaultFlowDiagSolution(); m_flowDiagSolution = m_case->defaultFlowDiagSolution();
} }
@@ -181,7 +181,7 @@ void RimWellAllocationPlot::setFromSimulationWell( RimSimWellInView* simWell )
// Use the active flow diag solutions, or the first one as default // Use the active flow diag solutions, or the first one as default
m_flowDiagSolution = eclView->cellResult()->flowDiagSolution(); m_flowDiagSolution = eclView->cellResult()->flowDiagSolution();
if ( !m_flowDiagSolution ) if ( ( m_flowDiagSolution == nullptr ) && ( m_case != nullptr ) )
{ {
m_flowDiagSolution = m_case->defaultFlowDiagSolution(); m_flowDiagSolution = m_case->defaultFlowDiagSolution();
} }
@@ -236,7 +236,7 @@ void RimWellConnectivityTable::setFromSimulationWell( RimSimWellInView* simWell
if ( eclView ) if ( eclView )
{ {
m_flowDiagSolution = eclView->cellResult()->flowDiagSolution(); m_flowDiagSolution = eclView->cellResult()->flowDiagSolution();
if ( !m_flowDiagSolution ) if ( ( m_flowDiagSolution == nullptr ) && ( m_case != nullptr ) )
{ {
m_flowDiagSolution = m_case->defaultFlowDiagSolution(); m_flowDiagSolution = m_case->defaultFlowDiagSolution();
} }
@@ -42,6 +42,7 @@ RigTofAccumulatedPhaseFractionsCalculator::RigTofAccumulatedPhaseFractionsCalcul
QString wellname, QString wellname,
size_t timestep ) size_t timestep )
{ {
if ( caseToApply == nullptr ) return;
RigEclipseCaseData* eclipseCaseData = caseToApply->eclipseCaseData(); RigEclipseCaseData* eclipseCaseData = caseToApply->eclipseCaseData();
if ( !eclipseCaseData ) return; if ( !eclipseCaseData ) return;