qmlls: don't check qmake versions for latest qmlls

Don't search for QMake versions in Qt kits when searching for the latest
qmlls version currently available.

Also clean up the code a bit, and break ties of Qt kits of the same
versions with their unique id, so that always the same qmlls is used
when multiple ones are available with the same version. This happens for
example when you have multiple Qt builds (one debug, one release, one
for documentation) based on the same source.

Change-Id: I0eb90d15c4e2b7c28c50f7ac1d3f976386b9b031
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
This commit is contained in:
Sami Shalayel
2025-02-27 11:32:54 +01:00
parent 5a78d8882b
commit 0ceec57c08

View File

@@ -74,34 +74,30 @@ static QtVersion *qtVersionFromProject(const Project *project)
static std::pair<FilePath, QVersionNumber> evaluateLatestQmlls()
{
// find latest qmlls, i.e. vals
if (!QtVersionManager::isLoaded())
return {};
const QtVersions versions = QtVersionManager::versions();
FilePath latestQmlls;
QVersionNumber latestVersion;
FilePath latestQmakeFilePath;
int latestUniqueId = std::numeric_limits<int>::min();
for (QtVersion *v : versions) {
// check if we find qmlls
QVersionNumber vNow = v->qtVersion();
FilePath qmllsNow = QmlJS::ModelManagerInterface::qmllsForBinPath(v->hostBinPath(), vNow);
if (!qmllsNow.isExecutableFile())
for (QtVersion *qtVersion : versions) {
const QVersionNumber version = qtVersion->qtVersion();
const int uniqueId = qtVersion->uniqueId();
// note: break ties between qt kits of same versions by selecting the qt kit with the highest id
if (std::tie(version, uniqueId) < std::tie(latestVersion, latestUniqueId))
continue;
if (latestVersion > vNow)
const FilePath qmlls
= QmlJS::ModelManagerInterface::qmllsForBinPath(qtVersion->hostBinPath(), version);
if (!qmlls.isExecutableFile())
continue;
FilePath qmakeNow = v->qmakeFilePath();
int uniqueIdNow = v->uniqueId();
if (latestVersion == vNow) {
if (latestQmakeFilePath > qmakeNow)
continue;
if (latestQmakeFilePath == qmakeNow && latestUniqueId >= v->uniqueId())
continue;
}
latestVersion = vNow;
latestQmlls = qmllsNow;
latestQmakeFilePath = qmakeNow;
latestUniqueId = uniqueIdNow;
latestVersion = version;
latestQmlls = qmlls;
latestUniqueId = uniqueId;
}
return std::make_pair(latestQmlls, latestVersion);
}