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 <marcus.tillmanns@qt.io>
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
Marcus Tillmanns
2023-06-29 10:57:12 +02:00
parent 6b6b1198dd
commit 2d1de55bdd

View File

@@ -141,8 +141,7 @@ public:
PortList freePorts; PortList freePorts;
FilePath debugServerPath; FilePath debugServerPath;
FilePath debugDumperPath = Core::ICore::resourcePath("debugger/"); FilePath debugDumperPath = Core::ICore::resourcePath("debugger/");
FilePath qmlRunCommand; std::optional<FilePath> qmlRunCommand;
bool qmlRunCommandChecked = false;
bool emptyCommandAllowed = false; bool emptyCommandAllowed = false;
QList<Icon> deviceIcons; QList<Icon> deviceIcons;
@@ -482,7 +481,9 @@ void IDevice::fromMap(const QVariantMap &map)
d->version = map.value(QLatin1String(VersionKey), 0).toInt(); d->version = map.value(QLatin1String(VersionKey), 0).toInt();
d->debugServerPath = FilePath::fromSettings(map.value(QLatin1String(DebugServerKey))); 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(); d->extraData = map.value(ExtraDataKey).toMap();
} }
@@ -515,7 +516,9 @@ QVariantMap IDevice::toMap() const
map.insert(QLatin1String(VersionKey), d->version); map.insert(QLatin1String(VersionKey), d->version);
map.insert(QLatin1String(DebugServerKey), d->debugServerPath.toSettings()); 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); map.insert(ExtraDataKey, d->extraData);
return map; return map;
@@ -604,20 +607,23 @@ void IDevice::setDebugServerPath(const FilePath &path)
FilePath IDevice::qmlRunCommand() const FilePath IDevice::qmlRunCommand() const
{ {
if (!d->qmlRunCommandChecked) { if (d->qmlRunCommand)
d->qmlRunCommandChecked = true; return *d->qmlRunCommand;
QString runtime = d->qmlRunCommand.path();
if (runtime.isEmpty()) const FilePath newPath = searchExecutableInPath("qml");
runtime = "qml"; if (newPath.isEmpty())
d->qmlRunCommand = searchExecutableInPath(runtime); return {};
}
return d->qmlRunCommand; d->qmlRunCommand = newPath;
return *d->qmlRunCommand;
} }
void IDevice::setQmlRunCommand(const FilePath &path) void IDevice::setQmlRunCommand(const FilePath &path)
{ {
d->qmlRunCommand = path; if (path.isEmpty())
d->qmlRunCommandChecked = false; d->qmlRunCommand.reset();
else
d->qmlRunCommand = path;
} }
void IDevice::setExtraData(Id kind, const QVariant &data) void IDevice::setExtraData(Id kind, const QVariant &data)