Commit ea0d3f9a authored by Ulf Hermann's avatar Ulf Hermann

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's avatarTobias Hunger <tobias.hunger@qt.io>
parent 2b2b06a6
......@@ -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()
......
......@@ -44,6 +44,7 @@ class PROJECTEXPLORER_EXPORT ProjectTree : public QObject
Q_OBJECT
public:
explicit ProjectTree(QObject *parent = nullptr);
~ProjectTree();
static ProjectTree *instance();
......
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