#11909 Add null pointer guards when detecting unit system

This commit is contained in:
Magne Sjaastad 2024-11-21 12:01:46 +01:00
parent 8da0690096
commit 065528ffba

View File

@ -808,6 +808,8 @@ void RimWellPathCollection::sortWellsByName()
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
caf::AppEnum<RiaDefines::EclipseUnitSystem> RimWellPathCollection::findUnitSystemForWellPath( const RimWellPath* wellPath ) caf::AppEnum<RiaDefines::EclipseUnitSystem> RimWellPathCollection::findUnitSystemForWellPath( const RimWellPath* wellPath )
{ {
if ( !wellPath || !wellPath->wellPathGeometry() ) return RiaDefines::EclipseUnitSystem::UNITS_UNKNOWN;
RimProject* project = RimProject::current(); RimProject* project = RimProject::current();
if ( project->activeOilField()->analysisModels->cases.empty() ) if ( project->activeOilField()->analysisModels->cases.empty() )
{ {
@ -815,8 +817,13 @@ caf::AppEnum<RiaDefines::EclipseUnitSystem> RimWellPathCollection::findUnitSyste
} }
const RigEclipseCaseData* eclipseCaseData = project->activeOilField()->analysisModels->cases()[0]->eclipseCaseData(); const RigEclipseCaseData* eclipseCaseData = project->activeOilField()->analysisModels->cases()[0]->eclipseCaseData();
cvf::BoundingBox caseBoundingBox = eclipseCaseData->mainGrid()->boundingBox(); if ( !eclipseCaseData || !eclipseCaseData->mainGrid() )
cvf::BoundingBox wellPathBoundingBox; {
return RiaDefines::EclipseUnitSystem::UNITS_UNKNOWN;
}
cvf::BoundingBox caseBoundingBox = eclipseCaseData->mainGrid()->boundingBox();
cvf::BoundingBox wellPathBoundingBox;
for ( const auto& wellPathPoint : wellPath->wellPathGeometry()->wellPathPoints() ) for ( const auto& wellPathPoint : wellPath->wellPathGeometry()->wellPathPoints() )
{ {
wellPathBoundingBox.add( wellPathPoint ); wellPathBoundingBox.add( wellPathPoint );