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;
FilePath debugServerPath;
FilePath debugDumperPath = Core::ICore::resourcePath("debugger/");
FilePath qmlRunCommand;
bool qmlRunCommandChecked = false;
std::optional<FilePath> qmlRunCommand;
bool emptyCommandAllowed = false;
QList<Icon> 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)
{
if (path.isEmpty())
d->qmlRunCommand.reset();
else
d->qmlRunCommand = path;
d->qmlRunCommandChecked = false;
}
void IDevice::setExtraData(Id kind, const QVariant &data)