From ea0d3f9ac515ce41b308436d36bbb7c2bc6c40ec Mon Sep 17 00:00:00 2001 From: Ulf Hermann <ulf.hermann@qt.io> Date: Mon, 30 May 2016 14:01:51 +0200 Subject: [PATCH] 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> --- src/plugins/projectexplorer/projecttree.cpp | 9 +++++++++ src/plugins/projectexplorer/projecttree.h | 1 + 2 files changed, 10 insertions(+) diff --git a/src/plugins/projectexplorer/projecttree.cpp b/src/plugins/projectexplorer/projecttree.cpp index 43710c1a36..3e89539aac 100644 --- a/src/plugins/projectexplorer/projecttree.cpp +++ b/src/plugins/projectexplorer/projecttree.cpp @@ -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() diff --git a/src/plugins/projectexplorer/projecttree.h b/src/plugins/projectexplorer/projecttree.h index 2a48995893..cd1ec25ef8 100644 --- a/src/plugins/projectexplorer/projecttree.h +++ b/src/plugins/projectexplorer/projecttree.h @@ -44,6 +44,7 @@ class PROJECTEXPLORER_EXPORT ProjectTree : public QObject Q_OBJECT public: explicit ProjectTree(QObject *parent = nullptr); + ~ProjectTree(); static ProjectTree *instance(); -- GitLab