diff --git a/ApplicationCode/Commands/RicImportFormationNamesFeature.cpp b/ApplicationCode/Commands/RicImportFormationNamesFeature.cpp index 0de007ebf3..ad55cc30b9 100644 --- a/ApplicationCode/Commands/RicImportFormationNamesFeature.cpp +++ b/ApplicationCode/Commands/RicImportFormationNamesFeature.cpp @@ -97,7 +97,7 @@ bool RicImportFormationNamesFeature::isCommandEnabled() //-------------------------------------------------------------------------------------------------- /// If only one formation file is imported, the formation will automatically be set in the active -/// view�s case. Import of LYR files with colors create custom color legends according to color +/// view’s case. Import of LYR files with colors create custom color legends according to color /// definition on each file. However, color legend must be set by the user. //-------------------------------------------------------------------------------------------------- void RicImportFormationNamesFeature::onActionTriggered( bool isChecked ) @@ -226,13 +226,17 @@ void RicImportFormationNamesFeature::setFormationCellResultAndLegend( Rim3dView* RimGeoMechView* geoMechView = dynamic_cast( activeView ); if ( geoMechView ) { - legendConfig = geoMechView->cellResult().p()->legendConfig; - // geoMechView->cellResult().p()->setResultType( RiaDefines::ResultCatType::FORMATION_NAMES ); - // geoMechView->cellResult().p()->setResultVariable( RiaDefines::activeFormationNamesResultName() ); + legendConfig = geoMechView->cellResult()->legendConfig(); } - RimColorLegendCollection* colorLegendCollection = RimProject::current()->colorLegendCollection; - RimColorLegend* legend = colorLegendCollection->findByName( legendName ); + if ( legendConfig ) + { + RimColorLegendCollection* colorLegendCollection = RimProject::current()->colorLegendCollection; - legendConfig->setColorLegend( legend ); + RimColorLegend* legend = colorLegendCollection->findByName( legendName ); + if ( legend ) + { + legendConfig->setColorLegend( legend ); + } + } }