diff --git a/ApplicationCode/Commands/RicShowGridStatisticsFeature.cpp b/ApplicationCode/Commands/RicShowGridStatisticsFeature.cpp index 7a5258a3b8..e059c4a67c 100644 --- a/ApplicationCode/Commands/RicShowGridStatisticsFeature.cpp +++ b/ApplicationCode/Commands/RicShowGridStatisticsFeature.cpp @@ -39,7 +39,7 @@ CAF_CMD_SOURCE_INIT(RicShowGridStatisticsFeature, "RicShowGridStatisticsFeature" //-------------------------------------------------------------------------------------------------- bool RicShowGridStatisticsFeature::isCommandEnabled() { - return true; + return RiaApplication::instance()->activeReservoirView() != nullptr; } //-------------------------------------------------------------------------------------------------- @@ -47,16 +47,11 @@ bool RicShowGridStatisticsFeature::isCommandEnabled() //-------------------------------------------------------------------------------------------------- void RicShowGridStatisticsFeature::onActionTriggered(bool isChecked) { - auto eclipseView = caf::firstAncestorOfTypeFromSelectedObject(); - auto geoMechView = caf::firstAncestorOfTypeFromSelectedObject(); + RimView * activeView = RiaApplication::instance()->activeReservoirView(); - if (eclipseView && eclipseView->overlayInfoConfig()) + if (activeView) { - eclipseView->overlayInfoConfig()->showStatisticsInfoDialog(); - } - else if (geoMechView && geoMechView->overlayInfoConfig()) - { - geoMechView->overlayInfoConfig()->showStatisticsInfoDialog(); + activeView->overlayInfoConfig()->showStatisticsInfoDialog(); } }