Commit 519a3659 authored by Tobias Hunger's avatar Tobias Hunger

ToolChainKitInformation: Make use of ToolChainManager::isLoaded()

Warn when trying to access values not yet initialized, and avoid
doing so. Also invalidate toolchains in kits properly.

Change-Id: I3a98a2ca89ce43d9982d37bdee451c5122c788b2
Reviewed-by: default avatarDaniel Teske <daniel.teske@digia.com>
parent 60cea5e1
......@@ -78,13 +78,10 @@ bool AndroidPlugin::initialize(const QStringList &arguments, QString *errorMessa
ProjectExplorer::DeviceManager::instance()
->addDevice(ProjectExplorer::IDevice::Ptr(new Internal::AndroidDevice));
return true;
}
void AndroidPlugin::extensionsInitialized()
{
connect(ProjectExplorer::KitManager::instance(), SIGNAL(kitsChanged()),
connect(ProjectExplorer::KitManager::instance(), SIGNAL(kitsLoaded()),
this, SLOT(kitsRestored()));
return true;
}
void AndroidPlugin::kitsRestored()
......
......@@ -43,7 +43,8 @@ public:
AndroidPlugin();
bool initialize(const QStringList &arguments, QString *errorMessage);
void extensionsInitialized();
void extensionsInitialized() { }
private slots:
void kitsRestored();
};
......
......@@ -34,6 +34,7 @@
#include <projectexplorer/abi.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/toolchain.h>
#include <projectexplorer/toolchainmanager.h>
#include <utils/environment.h>
#include <utils/qtcassert.h>
......@@ -201,6 +202,7 @@ DebuggerKitInformation::DebuggerItem DebuggerKitInformation::autoDetectItem(cons
void DebuggerKitInformation::setup(Kit *k)
{
QTC_ASSERT(ToolChainManager::instance()->isLoaded(), return);
setDebuggerItem(k, autoDetectItem(k));
}
......
......@@ -126,12 +126,8 @@ static const char TOOLCHAIN_INFORMATION[] = "PE.Profile.ToolChain";
ToolChainKitInformation::ToolChainKitInformation()
{
setObjectName(QLatin1String("ToolChainInformation"));
connect(ToolChainManager::instance(), SIGNAL(toolChainRemoved(ProjectExplorer::ToolChain*)),
this, SIGNAL(validationNeeded()));
connect(ToolChainManager::instance(), SIGNAL(toolChainUpdated(ProjectExplorer::ToolChain*)),
this, SIGNAL(validationNeeded()));
connect(ToolChainManager::instance(), SIGNAL(toolChainUpdated(ProjectExplorer::ToolChain*)),
this, SLOT(toolChainUpdated(ProjectExplorer::ToolChain*)));
connect(KitManager::instance(), SIGNAL(kitsLoaded()),
this, SLOT(kitsWereLoaded()));
}
Core::Id ToolChainKitInformation::dataId() const
......@@ -174,6 +170,7 @@ QList<Task> ToolChainKitInformation::validate(const Kit *k) const
void ToolChainKitInformation::fix(Kit *k)
{
QTC_ASSERT(ToolChainManager::instance()->isLoaded(), return);
if (toolChain(k))
return;
......@@ -184,6 +181,7 @@ void ToolChainKitInformation::fix(Kit *k)
void ToolChainKitInformation::setup(Kit *k)
{
QTC_ASSERT(ToolChainManager::instance()->isLoaded(), return);
const QString id = k->value(Core::Id(TOOLCHAIN_INFORMATION)).toString();
if (id.isEmpty())
return;
......@@ -233,6 +231,7 @@ IOutputParser *ToolChainKitInformation::createOutputParser(const Kit *k) const
ToolChain *ToolChainKitInformation::toolChain(const Kit *k)
{
QTC_ASSERT(ToolChainManager::instance()->isLoaded(), return 0);
if (!k)
return 0;
return ToolChainManager::instance()
......@@ -249,11 +248,29 @@ QString ToolChainKitInformation::msgNoToolChainInTarget()
return tr("No compiler set in kit.");
}
void ToolChainKitInformation::toolChainUpdated(ToolChain *tc)
void ToolChainKitInformation::kitsWereLoaded()
{
foreach (Kit *k, KitManager::instance()->kits())
if (toolChain(k) == tc)
notifyAboutUpdate(k);
fix(k);
connect(ToolChainManager::instance(), SIGNAL(toolChainRemoved(ProjectExplorer::ToolChain*)),
this, SLOT(toolChainRemoved(ProjectExplorer::ToolChain*)));
connect(ToolChainManager::instance(), SIGNAL(toolChainUpdated(ProjectExplorer::ToolChain*)),
this, SLOT(toolChainUpdated(ProjectExplorer::ToolChain*)));
}
void ToolChainKitInformation::toolChainUpdated(ProjectExplorer::ToolChain *tc)
{
ToolChainMatcher m(tc);
foreach (Kit *k, KitManager::instance()->kits(&m))
notifyAboutUpdate(k);
}
void ToolChainKitInformation::toolChainRemoved(ProjectExplorer::ToolChain *tc)
{
Q_UNUSED(tc);
foreach (Kit *k, KitManager::instance()->kits())
fix(k);
}
// --------------------------------------------------------------------------
......
......@@ -120,7 +120,9 @@ public:
static QString msgNoToolChainInTarget();
private slots:
void kitsWereLoaded();
void toolChainUpdated(ProjectExplorer::ToolChain *tc);
void toolChainRemoved(ProjectExplorer::ToolChain *tc);
};
class PROJECTEXPLORER_EXPORT ToolChainMatcher : public KitMatcher
......
......@@ -350,6 +350,7 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
// Register KitInformation:
KitManager::instance()->registerKitInformation(new DeviceTypeKitInformation);
KitManager::instance()->registerKitInformation(new DeviceKitInformation);
KitManager::instance()->registerKitInformation(new ToolChainKitInformation);
KitManager::instance()->registerKitInformation(new SysRootKitInformation);
addAutoReleasedObject(new Internal::ToolChainOptionsPage);
......@@ -1123,10 +1124,6 @@ void ProjectExplorerPlugin::extensionsInitialized()
}
d->m_buildManager->extensionsInitialized();
// Register KitInformation:
// Only do this now to make sure all device factories were properly initialized.
KitManager::instance()->registerKitInformation(new ToolChainKitInformation);
DeviceManager::instance()->addDevice(IDevice::Ptr(new DesktopDevice));
DeviceManager::instance()->load();
d->m_toolChainManager->restoreToolChains();
......
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