Commit c708944a authored by Tobias Hunger's avatar Tobias Hunger

Kit: Only emit signals from KitManager after all kits are restored

Change-Id: Iab5a951a3cec37328b5bcd9d8c3f9c1a31c3d85b
Reviewed-by: default avatarEike Ziller <eike.ziller@digia.com>
parent 75efa76e
...@@ -89,8 +89,7 @@ public: ...@@ -89,8 +89,7 @@ public:
}; };
KitManagerPrivate::KitManagerPrivate() KitManagerPrivate::KitManagerPrivate()
: m_defaultKit(0), m_initialized(false), : m_defaultKit(0), m_initialized(false), m_writer(0)
m_writer(0)
{ } { }
KitManagerPrivate::~KitManagerPrivate() KitManagerPrivate::~KitManagerPrivate()
...@@ -131,7 +130,15 @@ KitManager::KitManager(QObject *parent) : ...@@ -131,7 +130,15 @@ KitManager::KitManager(QObject *parent) :
void KitManager::restoreKits() void KitManager::restoreKits()
{ {
QTC_ASSERT(!d->m_writer, return); QTC_ASSERT(!d->m_initialized, return);
static bool initializing = false;
if (initializing) // kits will call kits() to check their display names, which will trigger another
// call to restoreKits, which ...
return;
initializing = true;
QList<Kit *> kitsToRegister; QList<Kit *> kitsToRegister;
QList<Kit *> kitsToValidate; QList<Kit *> kitsToValidate;
QList<Kit *> kitsToCheck; QList<Kit *> kitsToCheck;
...@@ -203,6 +210,7 @@ void KitManager::restoreKits() ...@@ -203,6 +210,7 @@ void KitManager::restoreKits()
setDefaultKit(k); setDefaultKit(k);
d->m_writer = new Utils::PersistentSettingsWriter(settingsFileName(), QLatin1String("QtCreatorProfiles")); d->m_writer = new Utils::PersistentSettingsWriter(settingsFileName(), QLatin1String("QtCreatorProfiles"));
d->m_initialized = true;
} }
KitManager::~KitManager() KitManager::~KitManager()
...@@ -319,10 +327,8 @@ KitManager::KitList KitManager::restoreKits(const Utils::FileName &fileName) ...@@ -319,10 +327,8 @@ KitManager::KitList KitManager::restoreKits(const Utils::FileName &fileName)
QList<Kit *> KitManager::kits(const KitMatcher *m) const QList<Kit *> KitManager::kits(const KitMatcher *m) const
{ {
if (!d->m_initialized) { if (!d->m_initialized)
d->m_initialized = true;
const_cast<KitManager *>(this)->restoreKits(); const_cast<KitManager *>(this)->restoreKits();
}
QList<Kit *> result; QList<Kit *> result;
foreach (Kit *k, d->m_kitList) { foreach (Kit *k, d->m_kitList) {
...@@ -350,12 +356,10 @@ Kit *KitManager::find(const KitMatcher *m) const ...@@ -350,12 +356,10 @@ Kit *KitManager::find(const KitMatcher *m) const
return matched.isEmpty() ? 0 : matched.first(); return matched.isEmpty() ? 0 : matched.first();
} }
Kit *KitManager::defaultKit() Kit *KitManager::defaultKit() const
{ {
if (!d->m_initialized) { if (!d->m_initialized)
d->m_initialized = true; const_cast<KitManager *>(this)->restoreKits();
restoreKits();
}
return d->m_defaultKit; return d->m_defaultKit;
} }
...@@ -377,7 +381,7 @@ void KitManager::notifyAboutUpdate(ProjectExplorer::Kit *k) ...@@ -377,7 +381,7 @@ void KitManager::notifyAboutUpdate(ProjectExplorer::Kit *k)
{ {
if (!k) if (!k)
return; return;
if (kits().contains(k)) if (kits().contains(k) && d->m_initialized)
emit kitUpdated(k); emit kitUpdated(k);
else else
emit unmanagedKitUpdated(k); emit unmanagedKitUpdated(k);
...@@ -394,7 +398,8 @@ bool KitManager::registerKit(ProjectExplorer::Kit *k) ...@@ -394,7 +398,8 @@ bool KitManager::registerKit(ProjectExplorer::Kit *k)
// make sure we have all the information in our kits: // make sure we have all the information in our kits:
addKit(k); addKit(k);
emit kitAdded(k); if (d->m_initialized)
emit kitAdded(k);
return true; return true;
} }
...@@ -414,7 +419,8 @@ void KitManager::deregisterKit(Kit *k) ...@@ -414,7 +419,8 @@ void KitManager::deregisterKit(Kit *k)
} }
setDefaultKit(newDefault); setDefaultKit(newDefault);
} }
emit kitRemoved(k); if (d->m_initialized)
emit kitRemoved(k);
delete k; delete k;
} }
...@@ -425,7 +431,8 @@ void KitManager::setDefaultKit(Kit *k) ...@@ -425,7 +431,8 @@ void KitManager::setDefaultKit(Kit *k)
if (k && !kits().contains(k)) if (k && !kits().contains(k))
return; return;
d->m_defaultKit = k; d->m_defaultKit = k;
emit defaultkitChanged(); if (d->m_initialized)
emit defaultkitChanged();
} }
void KitManager::validateKits() void KitManager::validateKits()
......
...@@ -110,7 +110,7 @@ public: ...@@ -110,7 +110,7 @@ public:
QList<Kit *> kits(const KitMatcher *m = 0) const; QList<Kit *> kits(const KitMatcher *m = 0) const;
Kit *find(const Core::Id &id) const; Kit *find(const Core::Id &id) const;
Kit *find(const KitMatcher *m) const; Kit *find(const KitMatcher *m) const;
Kit *defaultKit(); Kit *defaultKit() const;
QList<KitInformation *> kitInformation() const; QList<KitInformation *> kitInformation() const;
......
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