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