Commit b6ca2fc1 authored by Tobias Hunger's avatar Tobias Hunger

Kits: Make sure registered kits can not get deleted

Change-Id: I3b293ed9371b201e692fae7a7569239ebc8483e9
Reviewed-by: default avatarDaniel Teske <daniel.teske@digia.com>
parent dedbcd96
......@@ -43,7 +43,6 @@ namespace ProjectExplorer {
class IOutputParser;
namespace Internal {
class KitManagerPrivate;
class KitModel;
class KitPrivate;
} // namespace Internal
......@@ -58,7 +57,6 @@ class PROJECTEXPLORER_EXPORT Kit
{
public:
Kit(Core::Id id = Core::Id());
~Kit();
// Do not trigger evaluations
void blockNotification();
......@@ -98,6 +96,8 @@ public:
void copyFrom(const Kit *k);
private:
~Kit();
// Unimplemented.
Kit(const Kit &other);
void operator=(const Kit &other);
......
......@@ -95,7 +95,6 @@ KitManagerPrivate::KitManagerPrivate()
KitManagerPrivate::~KitManagerPrivate()
{
qDeleteAll(m_informationList);
qDeleteAll(m_kitList);
delete m_writer;
}
......@@ -192,7 +191,9 @@ void KitManager::restoreKits()
}
// Delete all loaded autodetected kits that were not rediscovered:
qDeleteAll(kitsToCheck);
foreach (Kit *k, kitsToCheck)
delete k;
kitsToCheck.clear();
// Store manual kits
foreach (Kit *k, kitsToRegister)
......@@ -221,7 +222,10 @@ void KitManager::restoreKits()
KitManager::~KitManager()
{
saveKits(); // Make sure we save the current state on exit!
// Clean out kit information to avoid calling them during deregistration:
foreach (Kit *k, d->m_kitList)
delete k;
d->m_kitList.clear();
delete d;
m_instance = 0;
}
......@@ -384,6 +388,12 @@ Internal::KitManagerConfigWidget *KitManager::createConfigWidget(Kit *k) const
return result;
}
void KitManager::deleteKit(Kit *k)
{
QTC_ASSERT(!KitManager::instance()->kits().contains(k), return);
delete k;
}
void KitManager::notifyAboutUpdate(ProjectExplorer::Kit *k)
{
if (!k)
......
......@@ -121,6 +121,8 @@ public:
Internal::KitManagerConfigWidget *createConfigWidget(Kit *k) const;
static void deleteKit(Kit *k);
public slots:
bool registerKit(ProjectExplorer::Kit *k);
void deregisterKit(ProjectExplorer::Kit *k);
......
......@@ -99,7 +99,7 @@ KitManagerConfigWidget::~KitManagerConfigWidget()
qDeleteAll(m_widgets);
m_widgets.clear();
delete m_modifiedKit;
KitManager::deleteKit(m_modifiedKit);
// Make sure our workingCopy did not get registered somehow:
foreach (const Kit *k, KitManager::instance()->kits())
QTC_CHECK(k->id() != Core::Id(WORKING_COPY_KIT_ID));
......
......@@ -2228,7 +2228,7 @@ Version11Handler::~Version11Handler()
QList<Kit *> knownKits = km->kits();
foreach (Kit *k, m_targets.keys()) {
if (!knownKits.contains(k))
delete k;
KitManager::deleteKit(k);
}
m_targets.clear();
}
......@@ -2314,13 +2314,13 @@ QVariantMap Version11Handler::update(Project *project, const QVariantMap &map)
const QString oldTargetId = extraTargetData.value(QLatin1String("ProjectExplorer.ProjectConfiguration.Id")).toString();
// Check each BCs/DCs and create profiles as needed
static Kit rawKit; // Do not needlessly use Core::Ids
Kit *rawKit = new Kit; // Do not needlessly use Core::Ids
QMapIterator<int, QVariantMap> buildIt(bcs);
while (buildIt.hasNext()) {
buildIt.next();
int bcPos = buildIt.key();
const QVariantMap &bc = buildIt.value();
Kit *tmpKit = &rawKit;
Kit *tmpKit = rawKit;
if (oldTargetId == QLatin1String("Qt4ProjectManager.Target.AndroidDeviceTarget")) {
tmpKit->setIconPath(QLatin1String(":/android/images/QtAndroid.png"));
......@@ -2442,6 +2442,7 @@ QVariantMap Version11Handler::update(Project *project, const QVariantMap &map)
m_targets[k].insert(QLatin1String("Update.IsActive"), true);
} // dcs
} // bcs
KitManager::deleteKit(rawKit);
} // read in map data
int newPos = 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