From 0e7c06bf87a17a7d977607df95a5f90f12049743 Mon Sep 17 00:00:00 2001 From: Nav Date: Sat, 17 Jul 2021 02:17:13 +0100 Subject: [PATCH] Fixed bug with default variant selection in Insight window The Insight window was failing to default to the first available variant when the user provided an invalid variant name in their config file. --- .../UserInterfaces/InsightWindow/InsightWindow.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Insight/UserInterfaces/InsightWindow/InsightWindow.cpp b/src/Insight/UserInterfaces/InsightWindow/InsightWindow.cpp index 7678dc1c..dd7a25ea 100644 --- a/src/Insight/UserInterfaces/InsightWindow/InsightWindow.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/InsightWindow.cpp @@ -205,14 +205,18 @@ void InsightWindow::activate() { if (this->supportedVariantsByName.contains(selectedVariantName)) { // The user has specified a valid variant name in their config file, so use that as the default this->selectVariant(&(this->supportedVariantsByName.at(selectedVariantName))); - } - } else { - if (this->targetConfig.variantName.has_value()) { + } else { Logger::error("Invalid target variant name \"" + this->targetConfig.variantName.value() + "\" - no such variant with the given name was found."); } + } + if (this->selectedVariant == nullptr) { + /* + * Given that we haven't been able to select a variant at this point, we will just fallback to the first + * one that is available. + */ this->selectVariant(&(this->supportedVariantsByName.begin()->second)); }