Add QtVersionManager::unsortedVersions()

To sort the list, we need to know the version number of all qt
versions. That requires running the qmake. Since in most cases
we don't need the sorted list at startup, add a method for that
and use it.

This prevents almost all calls to queryQmake for me, except for
a few for Android Qt Versions.

Change-Id: I6db89f214d68d07fee4b4dd15ee14c10d1248565
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
This commit is contained in:
Daniel Teske
2015-07-13 13:09:45 +02:00
committed by Orgad Shaneh
parent f54b7d63cc
commit 5f9d991062
4 changed files with 14 additions and 4 deletions

View File

@@ -1302,7 +1302,7 @@ void AndroidConfigurations::updateAutomaticKitList()
}
QHash<Abi, QList<QtSupport::BaseQtVersion *> > qtVersionsForArch;
foreach (QtSupport::BaseQtVersion *qtVersion, QtSupport::QtVersionManager::versions()) {
foreach (QtSupport::BaseQtVersion *qtVersion, QtSupport::QtVersionManager::unsortedVersions()) {
if (qtVersion->type() != QLatin1String(Constants::ANDROIDQT))
continue;
QList<Abi> qtAbis = qtVersion->qtAbis();

View File

@@ -60,7 +60,7 @@ QVariant QtKitInformation::defaultValue(ProjectExplorer::Kit *k) const
Q_UNUSED(k);
// find "Qt in PATH":
QList<BaseQtVersion *> versionList = QtVersionManager::versions();
QList<BaseQtVersion *> versionList = QtVersionManager::unsortedVersions();
BaseQtVersion *result = findOrDefault(versionList, [](const BaseQtVersion *v) {
return v->autodetectionSource() == QLatin1String("PATH");
});
@@ -174,7 +174,7 @@ int QtKitInformation::qtVersionId(const ProjectExplorer::Kit *k)
id = -1;
} else {
QString source = data.toString();
foreach (BaseQtVersion *v, QtVersionManager::versions()) {
foreach (BaseQtVersion *v, QtVersionManager::unsortedVersions()) {
if (v->autodetectionSource() != source)
continue;
id = v->uniqueId();

View File

@@ -354,7 +354,7 @@ void QtVersionManager::updateFromInstaller(bool emitSignal)
qDebug() << "";
}
}
foreach (BaseQtVersion *qtVersion, QtVersionManager::versions()) {
foreach (BaseQtVersion *qtVersion, m_versions) {
if (qtVersion->autodetectionSource().startsWith(QLatin1String("SDK."))) {
if (!sdkVersions.contains(qtVersion->autodetectionSource())) {
if (debug)
@@ -515,6 +515,13 @@ int QtVersionManager::getUniqueId()
return m_idcount++;
}
QList<BaseQtVersion *> QtVersionManager::unsortedVersions()
{
QList<BaseQtVersion *> versions;
QTC_ASSERT(isLoaded(), return versions);
return m_versions.values();
}
QList<BaseQtVersion *> QtVersionManager::versions()
{
QList<BaseQtVersion *> versions;

View File

@@ -56,6 +56,9 @@ public:
static QList<BaseQtVersion *> versions();
static QList<BaseQtVersion *> validVersions();
// Sorting is slow due to needing to potentially run qmake --query for each version
static QList<BaseQtVersion *> unsortedVersions();
// Note: DO NOT STORE THIS POINTER!
// The QtVersionManager will delete it at random times and you will
// need to get a new pointer by calling this function again!