Commit 5d253b37 authored by Tobias Hunger's avatar Tobias Hunger
Browse files

Make sure to never write kits/Qt/TCs before they were read



We should be save already, but let's be paranoid...

Change-Id: I925fb94f4cebe4c54e3419e18d307a999055ebbe
Reviewed-by: default avatarDaniel Teske <daniel.teske@digia.com>
parent ac6c11ec
......@@ -323,8 +323,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;
const_cast<KitManager *>(this)->restoreKits();
d->m_initialized = true;
}
QList<Kit *> result;
......@@ -356,8 +356,8 @@ Kit *KitManager::find(const KitMatcher *m) const
Kit *KitManager::defaultKit()
{
if (!d->m_initialized) {
d->m_initialized = true;
restoreKits();
d->m_initialized = true;
}
return d->m_defaultKit;
}
......
......@@ -39,6 +39,7 @@
#include <extensionsystem/pluginmanager.h>
#include <utils/persistentsettings.h>
#include <utils/qtcassert.h>
#include <QCoreApplication>
#include <QDir>
......@@ -81,7 +82,6 @@ public:
QList<ToolChain *> &toolChains();
ToolChainManager *q;
bool m_initialized;
QMap<QString, Utils::FileName> m_abiToDebugger;
Utils::PersistentSettingsWriter *m_writer;
......@@ -90,8 +90,7 @@ private:
};
ToolChainManagerPrivate::ToolChainManagerPrivate(ToolChainManager *parent)
: q(parent), m_initialized(false),
m_writer(new Utils::PersistentSettingsWriter(settingsFileName(QLatin1String(TOOLCHAIN_FILENAME)), QLatin1String("QtCreatorToolChains")))
: q(parent), m_writer(0)
{ }
ToolChainManagerPrivate::~ToolChainManagerPrivate()
......@@ -99,10 +98,8 @@ ToolChainManagerPrivate::~ToolChainManagerPrivate()
QList<ToolChain *> &ToolChainManagerPrivate::toolChains()
{
if (!m_initialized) {
m_initialized = true;
if (!m_writer)
q->restoreToolChains();
}
return m_toolChains;
}
......@@ -136,6 +133,10 @@ ToolChainManager::ToolChainManager(QObject *parent) :
void ToolChainManager::restoreToolChains()
{
QTC_ASSERT(!d->m_writer, return);
d->m_writer =
new Utils::PersistentSettingsWriter(settingsFileName(QLatin1String(TOOLCHAIN_FILENAME)), QLatin1String("QtCreatorToolChains"));
QList<ToolChain *> tcsToRegister;
QList<ToolChain *> tcsToCheck;
......
......@@ -177,6 +177,10 @@ QtVersionManager *QtVersionManager::instance()
bool QtVersionManager::restoreQtVersions()
{
QTC_ASSERT(!m_writer, return false);
m_writer = new Utils::PersistentSettingsWriter(settingsFileName(QLatin1String(QTVERSION_FILENAME)),
QLatin1String("QtCreatorQtVersions"));
QList<QtVersionFactory *> factories = ExtensionSystem::PluginManager::getObjects<QtVersionFactory>();
Utils::PersistentSettingsReader reader;
......@@ -362,8 +366,7 @@ void QtVersionManager::updateFromInstaller(bool emitSignal)
void QtVersionManager::saveQtVersions()
{
if (!m_writer)
m_writer = new Utils::PersistentSettingsWriter(settingsFileName(QLatin1String(QTVERSION_FILENAME)),
QLatin1String("QtCreatorQtVersions"));
return;
QVariantMap data;
data.insert(QLatin1String(QTVERSION_FILE_VERSION_KEY), 1);
......
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