Commit 33d1a91c authored by Daniel Teske's avatar Daniel Teske
Browse files

KitManager: Consider sdk kits for initial default kit



Change-Id: I86874f3d138f49d9962e11323364ba856b03bffd
Task-number: QTCREATORBUG-15002
Reviewed-by: default avatarTobias Hunger <tobias.hunger@theqtcompany.com>
parent 37a2cee1
......@@ -109,6 +109,13 @@ typename T::value_type findOr(const T &container, typename T::value_type other,
return *it;
}
template<typename T, typename R, typename S>
typename T::value_type findOr(const T &container, typename T::value_type other, R (S::*function)() const)
{
return findOr(container, other, std::mem_fn(function));
}
template<typename T, typename F>
int indexOf(const T &container, F function)
{
......@@ -127,6 +134,12 @@ typename T::value_type findOrDefault(const T &container, F function)
return findOr(container, typename T::value_type(), function);
}
template<typename T, typename R, typename S>
typename T::value_type findOrDefault(const T &container, R (S::*function)() const)
{
return findOr(container, typename T::value_type(), function);
}
//////////////////
// find helpers
//////////////////
......
......@@ -137,6 +137,7 @@ void KitManager::restoreKits()
QList<Kit *> kitsToRegister;
QList<Kit *> kitsToValidate;
QList<Kit *> kitsToCheck;
QList<Kit *> sdkKits;
// read all kits from SDK
QFileInfo systemSettingsFile(ICore::settings(QSettings::SystemScope)->fileName());
......@@ -193,6 +194,7 @@ void KitManager::restoreKits()
if (toStore == current)
toStore->setup();
addKit(toStore);
sdkKits << toStore;
}
// Delete all loaded autodetected kits that were not rediscovered:
......@@ -221,9 +223,14 @@ void KitManager::restoreKits()
if (k) {
setDefaultKit(k);
} else if (!defaultKit()) {
k = Utils::findOr(kitsToRegister, 0, [](Kit *k) { return k->isValid(); });
if (k)
k = Utils::findOrDefault(kitsToRegister, &Kit::isValid);
if (k) {
setDefaultKit(k);
} else {
k = Utils::findOrDefault(sdkKits, &Kit::isValid);
if (k)
setDefaultKit(k);
}
}
d->m_writer = new PersistentSettingsWriter(settingsFileName(), QLatin1String("QtCreatorProfiles"));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment