Commit e992ea1b authored by Tobias Hunger's avatar Tobias Hunger

Kits: Warn when initializing something too early/late

Warn when somebody tries to register KitInformation after kits are
already loaded. Also warn when trying to access kits before all
plugins are initialized.

This helps with making sure that initialization of plugins is done as
expected.

Change-Id: Ie2e9c79eee2a2c0de3397db9a95b5e41b614bfe8
Reviewed-by: default avatarDaniel Teske <daniel.teske@digia.com>
parent 5f68b5b0
...@@ -34,10 +34,12 @@ ...@@ -34,10 +34,12 @@
#include "kitinformation.h" #include "kitinformation.h"
#include "kitmanagerconfigwidget.h" #include "kitmanagerconfigwidget.h"
#include "project.h" #include "project.h"
#include "projectexplorer.h"
#include <coreplugin/icore.h> #include <coreplugin/icore.h>
#include <extensionsystem/pluginmanager.h> #include <extensionsystem/pluginmanager.h>
#include <extensionsystem/pluginspec.h>
#include <utils/persistentsettings.h> #include <utils/persistentsettings.h>
#include <utils/environment.h> #include <utils/environment.h>
...@@ -137,6 +139,7 @@ void KitManager::restoreKits() ...@@ -137,6 +139,7 @@ void KitManager::restoreKits()
return; return;
initializing = true; initializing = true;
QTC_CHECK(ProjectExplorerPlugin::instance()->pluginSpec()->state() == ExtensionSystem::PluginSpec::Running);
QList<Kit *> kitsToRegister; QList<Kit *> kitsToRegister;
QList<Kit *> kitsToValidate; QList<Kit *> kitsToValidate;
...@@ -261,6 +264,9 @@ bool greaterPriority(KitInformation *a, KitInformation *b) ...@@ -261,6 +264,9 @@ bool greaterPriority(KitInformation *a, KitInformation *b)
void KitManager::registerKitInformation(KitInformation *ki) void KitManager::registerKitInformation(KitInformation *ki)
{ {
QTC_CHECK(ProjectExplorerPlugin::instance()->pluginSpec()->state() <= ExtensionSystem::PluginSpec::Initialized);
QTC_CHECK(d->m_kitList.isEmpty());
QList<KitInformation *>::iterator it QList<KitInformation *>::iterator it
= qLowerBound(d->m_informationList.begin(), d->m_informationList.end(), ki, greaterPriority); = qLowerBound(d->m_informationList.begin(), d->m_informationList.end(), ki, greaterPriority);
d->m_informationList.insert(it, ki); d->m_informationList.insert(it, ki);
...@@ -456,7 +462,7 @@ void KitManager::setDefaultKit(Kit *k) ...@@ -456,7 +462,7 @@ void KitManager::setDefaultKit(Kit *k)
void KitManager::validateKits() void KitManager::validateKits()
{ {
foreach (Kit *k, kits()) foreach (Kit *k, d->m_kitList) // no need to load kits just to validate them!
k->validate(); k->validate();
} }
......
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