forked from qt-creator/qt-creator
TreeModel: Ensure that proxy models or views get notified...
...when the root item is exchanged. Change-Id: Ic854259902bcfdcf5ec5776ad40b56bca3820bf5 Reviewed-by: hjk <hjk@theqtcompany.com>
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user