From c478a80c5c58bb9e088bda513312543a02006bf7 Mon Sep 17 00:00:00 2001 From: James Turner <zakalawe@mac.com> Date: Wed, 30 Dec 2020 17:01:21 +0000 Subject: [PATCH] =?UTF-8?q?Launcher:=20don=E2=80=99t=20set=20empty=20METAR?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When an invalid custom METAR is entered, don’t pass it to FlightGear --- src/GUI/qml/Environment.qml | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/GUI/qml/Environment.qml b/src/GUI/qml/Environment.qml index 67d8d0ab3..42c1acb66 100644 --- a/src/GUI/qml/Environment.qml +++ b/src/GUI/qml/Environment.qml @@ -1,4 +1,5 @@ import QtQuick 2.4 +import QtQml 2.4 import FlightGear.Launcher 1.0 import "." @@ -150,10 +151,10 @@ Item { SettingLineEdit { id: customMETAR - property bool __cachedValid: true + property bool isMETARValid: false function revalidate() { - __cachedValid = _launcher.validateMetarString(value); + isMETARValid = _launcher.validateMetarString(value); } hidden: !weatherScenario.isCustomMETAR @@ -162,7 +163,7 @@ Item { placeholder: "XXXX 012345Z 28035G50KT 250V300 9999 TSRA SCT022CB BKN030 13/09 Q1005" useFullWidth: true setting: "custom-metar" - description: __cachedValid ? qsTr("Enter a custom METAR string, e.g: '%1'").arg(placeholder) + description: isMETARValid ? qsTr("Enter a custom METAR string, e.g: '%1'").arg(placeholder) : qsTr("The entered METAR string doesn't seem to be valid.") onValueChanged: { @@ -203,7 +204,9 @@ Item { } } else { if (weatherScenario.isCustomMETAR) { - _config.setArg("metar", customMETAR.value) + if (customMETAR.isMETARValid && (customMETAR.value != "")) { + _config.setArg("metar", customMETAR.value) + } } else { _config.setArg("metar", _weatherScenarios.metarForItem(index)) }