diff options
author | David Faure <david.faure@kdab.com> | 2020-03-05 17:56:32 +0100 |
---|---|---|
committer | David Faure <david.faure@kdab.com> | 2020-03-16 10:44:26 +0100 |
commit | 97422abcfcdf2c5c5b81b9de05ceb7bef6edcf13 (patch) | |
tree | 66847c9719a5fdf31f616c58edb6791342b58667 /tests/auto/widgets/itemviews | |
parent | f45d2dc54397fabca25de51fd0c9ec37014e46c8 (diff) |
QTreeView: don't call model.index(-1, 0) when using spanning items
drawTree() does
QPoint hoverPos = d->viewport->mapFromGlobal(QCursor::pos());
d->hoverBranch = d->itemDecorationAt(hoverPos);
and itemDecorationAt does
const QModelIndex index = q->indexAt(pos);
which might very well be an invalid index.
Change-Id: I7db98871543bd7e1c57fcc475d2646757bf2bb42
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
Diffstat (limited to 'tests/auto/widgets/itemviews')
-rw-r--r-- | tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp b/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp index 0580c466cf..b26516ee6b 100644 --- a/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp +++ b/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp @@ -270,6 +270,12 @@ public: QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override { + if (onlyValidCalls) { + Q_ASSERT(row >= 0); + Q_ASSERT(column >= 0); + Q_ASSERT(row < rows); + Q_ASSERT(column < cols); + } if (row < 0 || column < 0 || (level(parent) > levels) || column >= cols || row >= rows) { return QModelIndex(); } @@ -378,6 +384,7 @@ public: mutable bool fetched = false; bool decorationsEnabled = false; bool statusTipsEnabled = false; + bool onlyValidCalls = false; }; // Testing get/set functions @@ -2420,6 +2427,7 @@ void tst_QTreeView::hiddenItems() void tst_QTreeView::spanningItems() { QtTestModel model(10, 10); + model.onlyValidCalls = true; QTreeView view; view.setModel(&model); view.show(); @@ -2459,6 +2467,8 @@ void tst_QTreeView::spanningItems() } } QCOMPARE(view.sizeHintForColumn(0), w); + + view.repaint(); // to check that this doesn't hit any assert } void tst_QTreeView::selectionOrderTest() |