Device: Don't cache qmlRunCommand

Caching makes the settings page less snappy.

Also fixed searching for qml runtime if not set in
QmlProjectRunConfiguration

Fixes: QTCREATORBUG-29341
Change-Id: Ia3ce72f3e3b857a857f706694794304dcbf1793c
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
Reviewed-by: Robert Löhning <robert.loehning@qt.io>
This commit is contained in:
Marcus Tillmanns
2023-06-30 11:58:41 +02:00
parent 857f22e6c9
commit 57ff63bb96
2 changed files with 11 additions and 24 deletions

View File

@@ -141,7 +141,7 @@ public:
PortList freePorts; PortList freePorts;
FilePath debugServerPath; FilePath debugServerPath;
FilePath debugDumperPath = Core::ICore::resourcePath("debugger/"); FilePath debugDumperPath = Core::ICore::resourcePath("debugger/");
std::optional<FilePath> qmlRunCommand; FilePath qmlRunCommand;
bool emptyCommandAllowed = false; bool emptyCommandAllowed = false;
QList<Icon> deviceIcons; QList<Icon> deviceIcons;
@@ -482,8 +482,7 @@ void IDevice::fromMap(const QVariantMap &map)
d->debugServerPath = FilePath::fromSettings(map.value(QLatin1String(DebugServerKey))); d->debugServerPath = FilePath::fromSettings(map.value(QLatin1String(DebugServerKey)));
const FilePath qmlRunCmd = FilePath::fromSettings(map.value(QLatin1String(QmlRuntimeKey))); const FilePath qmlRunCmd = FilePath::fromSettings(map.value(QLatin1String(QmlRuntimeKey)));
if (!qmlRunCmd.isEmpty()) d->qmlRunCommand = qmlRunCmd;
d->qmlRunCommand = qmlRunCmd;
d->extraData = map.value(ExtraDataKey).toMap(); d->extraData = map.value(ExtraDataKey).toMap();
} }
@@ -516,8 +515,7 @@ 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), map.insert(QLatin1String(QmlRuntimeKey), d->qmlRunCommand.toSettings());
d->qmlRunCommand ? d->qmlRunCommand->toSettings() : FilePath().toSettings());
map.insert(ExtraDataKey, d->extraData); map.insert(ExtraDataKey, d->extraData);
@@ -607,23 +605,12 @@ void IDevice::setDebugServerPath(const FilePath &path)
FilePath IDevice::qmlRunCommand() const FilePath IDevice::qmlRunCommand() const
{ {
if (d->qmlRunCommand) return 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) void IDevice::setQmlRunCommand(const FilePath &path)
{ {
if (path.isEmpty()) d->qmlRunCommand = path;
d->qmlRunCommand.reset();
else
d->qmlRunCommand = path;
} }
void IDevice::setExtraData(Id kind, const QVariant &data) void IDevice::setExtraData(Id kind, const QVariant &data)

View File

@@ -207,15 +207,15 @@ FilePath QmlProjectRunConfiguration::qmlRuntimeFilePath() const
// We might not have a full Qt version for building, but the device // We might not have a full Qt version for building, but the device
// might know what is good for running. // might know what is good for running.
if (IDevice::ConstPtr dev = DeviceKitAspect::device(kit)) { IDevice::ConstPtr dev = DeviceKitAspect::device(kit);
if (dev) {
const FilePath qmlRuntime = dev->qmlRunCommand(); const FilePath qmlRuntime = dev->qmlRunCommand();
if (!qmlRuntime.isEmpty()) if (!qmlRuntime.isEmpty())
return qmlRuntime; return qmlRuntime;
} }
// The Qt version might know. That's the "build" Qt version, // The Qt version might know, but we need to make sure
// i.e. not necessarily something the device can use, but the // that the device can reach it.
// device had its chance above.
if (QtVersion *version = QtKitAspect::qtVersion(kit)) { if (QtVersion *version = QtKitAspect::qtVersion(kit)) {
// look for puppet as qmlruntime only in QtStudio Qt versions // look for puppet as qmlruntime only in QtStudio Qt versions
if (version->features().contains("QtStudio") && if (version->features().contains("QtStudio") &&
@@ -229,13 +229,13 @@ FilePath QmlProjectRunConfiguration::qmlRuntimeFilePath() const
} }
} }
const FilePath qmlRuntime = version->qmlRuntimeFilePath(); const FilePath qmlRuntime = version->qmlRuntimeFilePath();
if (!qmlRuntime.isEmpty()) if (!qmlRuntime.isEmpty() && (!dev || dev->ensureReachable(qmlRuntime)))
return qmlRuntime; return qmlRuntime;
} }
// If not given explicitly by run device, nor Qt, try to pick // If not given explicitly by run device, nor Qt, try to pick
// it from $PATH on the run device. // it from $PATH on the run device.
return "qml"; return dev ? dev->filePath("qml").searchInPath() : "qml";
} }
void QmlProjectRunConfiguration::createQtVersionAspect() void QmlProjectRunConfiguration::createQtVersionAspect()