From 133af73b2a50c84edc67c87a483f2aa2057d2894 Mon Sep 17 00:00:00 2001 From: Christian Stenger Date: Fri, 25 Sep 2015 13:38:43 +0200 Subject: [PATCH] TreeModel: Ensure that proxy models or views get notified... ...when the root item is exchanged. Change-Id: Ic854259902bcfdcf5ec5776ad40b56bca3820bf5 Reviewed-by: hjk --- src/libs/utils/treemodel.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/libs/utils/treemodel.cpp b/src/libs/utils/treemodel.cpp index 4a34181d2b5..d761ba5e9cf 100644 --- a/src/libs/utils/treemodel.cpp +++ b/src/libs/utils/treemodel.cpp @@ -967,9 +967,14 @@ void TreeModel::setRootItem(TreeItem *item) QTC_ASSERT(item->m_model == 0, return); QTC_ASSERT(item->m_parent == 0, return); QTC_CHECK(m_root); + + emit layoutAboutToBeChanged(); if (m_root) { QTC_CHECK(m_root->m_parent == 0); QTC_CHECK(m_root->m_model == this); + // needs to be done explicitly before setting the model to 0, otherwise it might lead to a + // crash inside a view or proxy model, especially if there are selected items + m_root->removeChildren(); m_root->m_model = 0; delete m_root; }