From 2d1de55bdde16495ad4bc1bec1a37979261b7785 Mon Sep 17 00:00:00 2001 From: Marcus Tillmanns Date: Thu, 29 Jun 2023 10:57:12 +0200 Subject: [PATCH] ProjectExplorer: Fix qmlRunCommand caching Previously the value set by the user was lost when the settings dialog is opened again. Change-Id: Ic6e977e2287671b460a4115d88580a44d4b10b74 Reviewed-by: Marcus Tillmanns Reviewed-by: Tim Jenssen --- .../projectexplorer/devicesupport/idevice.cpp | 34 +++++++++++-------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/src/plugins/projectexplorer/devicesupport/idevice.cpp b/src/plugins/projectexplorer/devicesupport/idevice.cpp index 12ff8e3cac3..ebcfeb95afa 100644 --- a/src/plugins/projectexplorer/devicesupport/idevice.cpp +++ b/src/plugins/projectexplorer/devicesupport/idevice.cpp @@ -141,8 +141,7 @@ public: PortList freePorts; FilePath debugServerPath; FilePath debugDumperPath = Core::ICore::resourcePath("debugger/"); - FilePath qmlRunCommand; - bool qmlRunCommandChecked = false; + std::optional qmlRunCommand; bool emptyCommandAllowed = false; QList deviceIcons; @@ -482,7 +481,9 @@ void IDevice::fromMap(const QVariantMap &map) d->version = map.value(QLatin1String(VersionKey), 0).toInt(); d->debugServerPath = FilePath::fromSettings(map.value(QLatin1String(DebugServerKey))); - d->qmlRunCommand = FilePath::fromSettings(map.value(QLatin1String(QmlRuntimeKey))); + const FilePath qmlRunCmd = FilePath::fromSettings(map.value(QLatin1String(QmlRuntimeKey))); + if (!qmlRunCmd.isEmpty()) + d->qmlRunCommand = qmlRunCmd; d->extraData = map.value(ExtraDataKey).toMap(); } @@ -515,7 +516,9 @@ QVariantMap IDevice::toMap() const map.insert(QLatin1String(VersionKey), d->version); map.insert(QLatin1String(DebugServerKey), d->debugServerPath.toSettings()); - map.insert(QLatin1String(QmlRuntimeKey), d->qmlRunCommand.toSettings()); + map.insert(QLatin1String(QmlRuntimeKey), + d->qmlRunCommand ? d->qmlRunCommand->toSettings() : FilePath().toSettings()); + map.insert(ExtraDataKey, d->extraData); return map; @@ -604,20 +607,23 @@ void IDevice::setDebugServerPath(const FilePath &path) FilePath IDevice::qmlRunCommand() const { - if (!d->qmlRunCommandChecked) { - d->qmlRunCommandChecked = true; - QString runtime = d->qmlRunCommand.path(); - if (runtime.isEmpty()) - runtime = "qml"; - d->qmlRunCommand = searchExecutableInPath(runtime); - } - return d->qmlRunCommand; + if (d->qmlRunCommand) + return *d->qmlRunCommand; + + const FilePath newPath = searchExecutableInPath("qml"); + if (newPath.isEmpty()) + return {}; + + d->qmlRunCommand = newPath; + return *d->qmlRunCommand; } void IDevice::setQmlRunCommand(const FilePath &path) { - d->qmlRunCommand = path; - d->qmlRunCommandChecked = false; + if (path.isEmpty()) + d->qmlRunCommand.reset(); + else + d->qmlRunCommand = path; } void IDevice::setExtraData(Id kind, const QVariant &data)