Fix TreeModel emitting nested QAbstractItemModel signals

This led to an assert in QSFPM because it got confused by the
nested reset signals.

Detected by adding
new QAbstractItemModelTester(this,
QAbstractItemModelTester::FailureReportingMode::Fatal);
to the OutlineModel constructor, and just opening QtCreator on a small
qmake-based project.

Fixes: QTCREATORBUG-30035
Change-Id: I41dbc81b5a2275521ece6b865115e1428e07ecf7
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: hjk <hjk@qt.io>
(cherry picked from commit 9124833a63)
Reviewed-by: David Faure <david.faure@kdab.com>
This commit is contained in:
David Faure
2023-11-29 10:46:55 +01:00
committed by David Schulz
parent a213ce3875
commit a61f9162f1
3 changed files with 20 additions and 6 deletions

View File

@@ -39,6 +39,7 @@ public:
void removeChildAt(int pos);
void removeChildren();
void removeChildrenSilently();
void sortChildren(const std::function<bool(const TreeItem *, const TreeItem *)> &cmp);
void update();
void updateAll();
@@ -180,7 +181,8 @@ protected:
void clear();
TreeItem *rootItem() const;
void setRootItem(TreeItem *item);
void setRootItem(TreeItem *item); // resets the model
void setRootItemInternal(TreeItem *item);
TreeItem *itemForIndex(const QModelIndex &) const;
QModelIndex indexForItem(const TreeItem *needle) const;