#9722 Grid Group Statistics: Guard accessing empty data structures

This commit is contained in:
Magne Sjaastad
2023-01-24 12:59:44 +01:00
parent 583c248cf9
commit a770f89082

View File

@@ -36,11 +36,6 @@ cvf::ref<RigResultModifier> RigResultModifierFactory::createResultModifier( RigE
{ {
if ( !eclipseCase ) return nullptr; if ( !eclipseCase ) return nullptr;
if ( !eclipseCase->results( porosityModel ) || !eclipseCase->activeCellInfo( porosityModel ) )
{
return nullptr;
}
if ( !resVarAddr.isValid() ) if ( !resVarAddr.isValid() )
{ {
return nullptr; return nullptr;
@@ -52,8 +47,15 @@ cvf::ref<RigResultModifier> RigResultModifierFactory::createResultModifier( RigE
return nullptr; return nullptr;
} }
auto scalarSetResults = eclipseCase->results( porosityModel )->modifiableCellScalarResultTimesteps( resVarAddr ); if ( !eclipseCase->results( porosityModel ) || !eclipseCase->activeCellInfo( porosityModel ) )
{
return nullptr;
}
auto cellResultsData = eclipseCase->results( porosityModel );
if ( !cellResultsData->hasResultEntry( resVarAddr ) ) return nullptr;
auto scalarSetResults = cellResultsData->modifiableCellScalarResultTimesteps( resVarAddr );
if ( timeStepIndex >= scalarSetResults->size() ) if ( timeStepIndex >= scalarSetResults->size() )
{ {
return nullptr; return nullptr;
@@ -67,16 +69,14 @@ cvf::ref<RigResultModifier> RigResultModifierFactory::createResultModifier( RigE
if ( resultValues->empty() ) return nullptr; if ( resultValues->empty() ) return nullptr;
bool useGlobalActiveIndex = eclipseCase->results( porosityModel )->isUsingGlobalActiveIndex( resVarAddr ); bool useGlobalActiveIndex = cellResultsData->isUsingGlobalActiveIndex( resVarAddr );
if ( useGlobalActiveIndex ) if ( useGlobalActiveIndex )
{ {
cvf::ref<RigResultModifier> object = cvf::ref<RigResultModifier> object =
new RigActiveCellsResultModifier( grid, eclipseCase->activeCellInfo( porosityModel ), resultValues ); new RigActiveCellsResultModifier( grid, eclipseCase->activeCellInfo( porosityModel ), resultValues );
return object; return object;
} }
else
{ cvf::ref<RigResultModifier> object = new RigAllGridCellsResultModifier( grid, resultValues );
cvf::ref<RigResultModifier> object = new RigAllGridCellsResultModifier( grid, resultValues ); return object;
return object;
}
} }