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