QmlProjectManager: Re-organize fallbacks for runtime search

This was getting messy.

Change-Id: Idce960b393fa02c5a032bb3a0c93929604d77f17
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
hjk
2022-12-16 12:37:19 +01:00
parent 6a4123a96f
commit d53842d512

View File

@@ -199,31 +199,27 @@ FilePath QmlProjectRunConfiguration::qmlRuntimeFilePath() const
return qmlViewer; return qmlViewer;
Kit *kit = target()->kit(); Kit *kit = target()->kit();
IDevice::ConstPtr dev = DeviceKitAspect::device(kit);
if (!dev.isNull()) { // We might not have a full Qt version for building, but the device
// might know what is good for running.
if (IDevice::ConstPtr dev = DeviceKitAspect::device(kit)) {
const FilePath qmlRuntime = dev->qmlRunCommand(); const FilePath qmlRuntime = dev->qmlRunCommand();
if (!qmlRuntime.isEmpty()) if (!qmlRuntime.isEmpty())
return qmlRuntime; return qmlRuntime;
} }
// If not given explicitly by device, try to pick it from $PATH. // The Qt version might know. That's the "build" Qt version,
QtVersion *version = QtKitAspect::qtVersion(kit); // i.e. not necessarily something the device can use, but the
if (!version) // No Qt version in Kit. Don't try to run QML runtime. // device had its chance above.
return {}; if (QtVersion *version = QtKitAspect::qtVersion(kit)) {
const FilePath qmlRuntime = version->qmlRuntimeFilePath();
const Id deviceType = DeviceTypeKitAspect::deviceTypeId(kit); if (!qmlRuntime.isEmpty())
if (deviceType == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE) { return qmlRuntime;
// If not given explicitly by Qt Version, try to pick it from $PATH.
const bool isDesktop = version->type() == QtSupport::Constants::DESKTOPQT;
return isDesktop ? version->qmlRuntimeFilePath() : "qmlscene";
} }
if (dev.isNull()) // No device set. We don't know where a QML utility is. // If not given explicitly by run device, nor Qt, try to pick
return {}; // it from $PATH on the run device.
return "qml";
const FilePath qmlRuntime = dev->qmlRunCommand();
// If not given explicitly by device, try to pick it from $PATH.
return qmlRuntime.isEmpty() ? "qml" : qmlRuntime;
} }
void QmlProjectRunConfiguration::createQtVersionAspect() void QmlProjectRunConfiguration::createQtVersionAspect()