Commit aef18a4b authored by Tobias Hunger's avatar Tobias Hunger
Browse files

ToolChainManager: Load tool chains in extensionsInitialized()



Change-Id: Iecbdad090c43fdabfb2d3ceac65fbbb2a72b33c2
Reviewed-by: default avatarDaniel Teske <daniel.teske@digia.com>
parent f30b4db8
......@@ -1128,6 +1128,7 @@ void ProjectExplorerPlugin::extensionsInitialized()
if (dm->find(Core::Id(Constants::DESKTOP_DEVICE_ID)).isNull())
DeviceManager::instance()->addDevice(IDevice::Ptr(new DesktopDevice));
dm->load();
d->m_toolChainManager->restoreToolChains();
}
void ProjectExplorerPlugin::loadCustomWizards()
......
......@@ -80,13 +80,10 @@ public:
ToolChainManagerPrivate(ToolChainManager *parent);
~ToolChainManagerPrivate();
QList<ToolChain *> &toolChains();
ToolChainManager *q;
QMap<QString, Utils::FileName> m_abiToDebugger;
Utils::PersistentSettingsWriter *m_writer;
private:
QList<ToolChain *> m_toolChains;
};
......@@ -101,13 +98,6 @@ ToolChainManagerPrivate::~ToolChainManagerPrivate()
delete m_writer;
}
QList<ToolChain *> &ToolChainManagerPrivate::toolChains()
{
if (!m_writer)
q->restoreToolChains();
return m_toolChains;
}
} // namespace Internal
// --------------------------------------------------------------------------
......@@ -139,7 +129,6 @@ ToolChainManager::ToolChainManager(QObject *parent) :
void ToolChainManager::restoreToolChains()
{
QTC_ASSERT(!d->m_writer, return);
QTC_CHECK(ProjectExplorerPlugin::instance()->pluginSpec()->state() == ExtensionSystem::PluginSpec::Running);
d->m_writer =
new Utils::PersistentSettingsWriter(settingsFileName(QLatin1String(TOOLCHAIN_FILENAME)), QLatin1String("QtCreatorToolChains"));
......@@ -209,6 +198,8 @@ void ToolChainManager::restoreToolChains()
// Store manual tool chains
foreach (ToolChain *tc, tcsToRegister)
registerToolChain(tc);
emit toolChainsLoaded();
}
ToolChainManager::~ToolChainManager()
......@@ -223,7 +214,7 @@ void ToolChainManager::saveToolChains()
data.insert(QLatin1String(TOOLCHAIN_FILE_VERSION_KEY), 1);
int count = 0;
foreach (ToolChain *tc, d->toolChains()) {
foreach (ToolChain *tc, d->m_toolChains) {
if (tc->isValid()) {
QVariantMap tmp = tc->toMap();
if (tmp.isEmpty())
......@@ -290,18 +281,19 @@ QList<ToolChain *> ToolChainManager::restoreToolChains(const Utils::FileName &fi
qPrintable(ToolChainFactory::idFromMap(tcMap)),
qPrintable(fileName.toUserOutput()));
}
return result;
}
QList<ToolChain *> ToolChainManager::toolChains() const
{
return d->toolChains();
return d->m_toolChains;
}
QList<ToolChain *> ToolChainManager::findToolChains(const Abi &abi) const
{
QList<ToolChain *> result;
foreach (ToolChain *tc, toolChains()) {
foreach (ToolChain *tc, d->m_toolChains) {
Abi targetAbi = tc->targetAbi();
if (targetAbi.isCompatibleWith(abi))
result.append(tc);
......@@ -314,7 +306,7 @@ ToolChain *ToolChainManager::findToolChain(const QString &id) const
if (id.isEmpty())
return 0;
foreach (ToolChain *tc, d->toolChains()) {
foreach (ToolChain *tc, d->m_toolChains) {
if (tc->id() == id)
return tc;
}
......@@ -326,32 +318,39 @@ Utils::FileName ToolChainManager::defaultDebugger(const Abi &abi) const
return d->m_abiToDebugger.value(abi.toString());
}
bool ToolChainManager::isLoaded() const
{
return d->m_writer;
}
void ToolChainManager::notifyAboutUpdate(ProjectExplorer::ToolChain *tc)
{
if (!tc || !toolChains().contains(tc))
if (!tc || !d->m_toolChains.contains(tc))
return;
emit toolChainUpdated(tc);
}
bool ToolChainManager::registerToolChain(ToolChain *tc)
{
if (!tc || d->toolChains().contains(tc))
QTC_ASSERT(d->m_writer, return false);
if (!tc || d->m_toolChains.contains(tc))
return true;
foreach (ToolChain *current, d->toolChains()) {
foreach (ToolChain *current, d->m_toolChains) {
if (*tc == *current && !tc->isAutoDetected())
return false;
}
d->toolChains().append(tc);
d->m_toolChains.append(tc);
emit toolChainAdded(tc);
return true;
}
void ToolChainManager::deregisterToolChain(ToolChain *tc)
{
if (!tc || !d->toolChains().contains(tc))
if (!tc || !d->m_toolChains.contains(tc))
return;
d->toolChains().removeOne(tc);
d->m_toolChains.removeOne(tc);
emit toolChainRemoved(tc);
delete tc;
}
......
......@@ -66,6 +66,8 @@ public:
Utils::FileName defaultDebugger(const Abi &abi) const;
bool isLoaded() const;
public slots:
bool registerToolChain(ProjectExplorer::ToolChain *tc);
void deregisterToolChain(ProjectExplorer::ToolChain *tc);
......@@ -81,6 +83,8 @@ signals:
// Something changed:
void toolChainsChanged();
void toolChainsLoaded();
private:
explicit ToolChainManager(QObject *parent = 0);
......
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