diff options
author | Christian Ehrlicher <ch.ehrlicher@gmx.de> | 2019-06-12 20:49:06 +0200 |
---|---|---|
committer | Christian Ehrlicher <ch.ehrlicher@gmx.de> | 2019-11-14 20:47:45 +0200 |
commit | c15a069830baf87f57c84e86326cf86ba9a39713 (patch) | |
tree | 3eb2afa9c6f22bb35ba647f17bb82dd5485fe5af /tests/auto/widgets/itemviews | |
parent | 80ac9e8b7ce8e3f79af0b00610a0a4b0ff17abe4 (diff) | |
download | qtbase-c15a069830baf87f57c84e86326cf86ba9a39713.tar.gz |
QTreeView: make sure to not ask the old model during setModel
Within QTreeView::setModel() the header might emit columnCountChanged
which then tries to update the geometries based on the old model which
is wrong.
Fix it by setting geometryRecursionBlock to true so
QTreeView::updateGeometries() will not ask the old model for it's data.
Fixes: QTBUG-75982
Change-Id: Ia0dd36cd7c6c5347fbc285deac43da6941accbe7
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Diffstat (limited to 'tests/auto/widgets/itemviews')
-rw-r--r-- | tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp b/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp index 44195d3b25..58ca924fe2 100644 --- a/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp +++ b/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp @@ -2862,6 +2862,7 @@ public: }; Node *root; + bool crash = false; EvilModel(QObject *parent = nullptr): QAbstractItemModel(parent), root(new Node) {} @@ -2870,6 +2871,11 @@ public: delete root; } + void setCrash() + { + crash = true; + } + void change() { emit layoutAboutToBeChanged(); @@ -2938,6 +2944,10 @@ public: QVariant data(const QModelIndex &idx, int role) const override { + if (crash) { + QTest::qFail("Should not get here...", __FILE__, __LINE__); + return QVariant(); + } if (idx.isValid() && role == Qt::DisplayRole) { Node *parentNode = root; if (idx.isValid()) { @@ -2957,6 +2967,7 @@ void tst_QTreeView::evilModel_data() { QTest::addColumn<bool>("visible"); QTest::newRow("visible") << false; + QTest::newRow("visible") << true; } void tst_QTreeView::evilModel() @@ -3126,6 +3137,9 @@ void tst_QTreeView::evilModel() model.change(); view.setRootIndex(secondLevel); + + model.setCrash(); + view.setModel(nullptr); } void tst_QTreeView::indexRowSizeHint() |