summaryrefslogtreecommitdiffstats
path: root/src/widgets/itemviews
diff options
context:
space:
mode:
authorVolker Hilsheimer <volker.hilsheimer@qt.io>2023-02-26 16:45:10 +0100
committerVolker Hilsheimer <volker.hilsheimer@qt.io>2023-02-28 18:19:24 +0100
commit85ab3f26656b2b51eaa5b5247cc0d90d401fd8df (patch)
tree5b3d2d74b5558757a1fc0f7fd7132e907a86b949 /src/widgets/itemviews
parentf952e74cfea438a5a411454cb50d470cd5928be7 (diff)
QAbstractItemView: execute posted layouts before painting
tst_QListView::moveLastRow asserts now and again, unless only that test function is running. We repeat failing test functions individually, so this never blocked CI. The reason seems to be that we get a paint event only for the viewport, after the item model's structure has been changed by the test. Moving rows does trigger a delayed layout, and in some circumstances the entire view is updated, rather than just the viewport. But if only the viewport is updated, then layout execution in QAbstractItemView::event never happens, and the data structure that the paintEvent implementation relies on is outdated and contains invalid item pointers, resulting in an assert. If we need to execute delayed layouts when the entire view gets painted, then we also need to execute them when only the viewport gets painted. Pick-to: 6.5 6.4 Change-Id: Ibb46c2315825d99c82b884226817c494a3d95975 Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Diffstat (limited to 'src/widgets/itemviews')
-rw-r--r--src/widgets/itemviews/qabstractitemview.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/widgets/itemviews/qabstractitemview.cpp b/src/widgets/itemviews/qabstractitemview.cpp
index 1be7e8ca51..22819fb51a 100644
--- a/src/widgets/itemviews/qabstractitemview.cpp
+++ b/src/widgets/itemviews/qabstractitemview.cpp
@@ -1709,6 +1709,12 @@ bool QAbstractItemView::viewportEvent(QEvent *event)
{
Q_D(QAbstractItemView);
switch (event->type()) {
+ case QEvent::Paint:
+ // Similar to pre-painting in QAbstractItemView::event to update scrollbar
+ // visibility, make sure that all pending layout requests have been executed
+ // so that the view's data structures are up-to-date before rendering.
+ d->executePostedLayout();
+ break;
case QEvent::HoverMove:
case QEvent::HoverEnter:
d->setHoverIndex(indexAt(static_cast<QHoverEvent*>(event)->position().toPoint()));