ProjectExplorer: Delete all the widgets when deleting the project tree

Leaving them around is dangerous as they rely on the tree to be valid.
When unloading the plugin the ProjectTree instance is deleted.

Change-Id: Iea6524b0c57c469045cb35f3cd2f376e579b8a57
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
Ulf Hermann
2016-05-30 14:01:51 +02:00
parent 2b2b06a6d3
commit ea0d3f9ac5
2 changed files with 10 additions and 0 deletions

View File

@@ -32,6 +32,7 @@
#include "nodesvisitor.h"
#include <utils/algorithm.h>
#include <utils/qtcassert.h>
#include <coreplugin/icore.h>
#include <coreplugin/editormanager/ieditor.h>
#include <coreplugin/editormanager/editormanager.h>
@@ -78,11 +79,19 @@ ProjectTree::ProjectTree(QObject *parent) : QObject(parent)
this, &ProjectTree::sessionChanged);
}
ProjectTree::~ProjectTree()
{
QTC_ASSERT(s_instance == this, return);
s_instance = nullptr;
}
void ProjectTree::aboutToShutDown()
{
disconnect(qApp, &QApplication::focusChanged,
s_instance, &ProjectTree::focusChanged);
s_instance->update(0, 0);
qDeleteAll(s_instance->m_projectTreeWidgets);
QTC_CHECK(s_instance->m_projectTreeWidgets.isEmpty());
}
ProjectTree *ProjectTree::instance()