summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Mutz <[email protected]>2025-03-26 10:27:44 +0100
committerMarc Mutz <[email protected]>2025-03-27 11:14:50 +0100
commit3b3b5968d0a51a1aa3a402f8e042f3a5a2c3329e (patch)
tree20ee948b025683313589b06a6c86f51e14dc50fd
parent9ea9818eeb29e79e7f12505a21669902d443dc1f (diff)
QAbstractItemView: fix UB (invalid downcast) in Private::shouldAutoScroll()
Says UBSan: qabstractitemview.cpp:4442:18: runtime error: downcast of address 0x604000026790 which does not point to an object of type 'QAbstractItemView' 0x604000026790: note: object is of type 'QWidget' 00 00 00 00 08 b1 cf 9f 33 7f 00 00 80 24 00 00 60 61 00 00 b8 b2 cf 9f 33 7f 00 00 00 00 be be ^~~~~~~~~~~~~~~~~~~~~~~ vptr for 'QWidget' I did not reserch what the problem was that the code comment referred to, but we now have QWidgetPrivate::get() (incl. in 5.15), so use that. Amends the start of the public history. Pick-to: 6.9 6.8 6.5 5.15 Change-Id: If658d21694f6806eafdf678b8d5ff7ed62e93513 Reviewed-by: Friedemann Kleint <[email protected]>
-rw-r--r--src/widgets/itemviews/qabstractitemview.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/widgets/itemviews/qabstractitemview.cpp b/src/widgets/itemviews/qabstractitemview.cpp
index d5744b456ab..090ac232a6e 100644
--- a/src/widgets/itemviews/qabstractitemview.cpp
+++ b/src/widgets/itemviews/qabstractitemview.cpp
@@ -4434,7 +4434,7 @@ bool QAbstractItemViewPrivate::shouldAutoScroll(const QPoint &pos) const
{
if (!autoScroll)
return false;
- QRect area = static_cast<QAbstractItemView*>(viewport)->d_func()->clipRect(); // access QWidget private by bending C++ rules
+ const QRect area = QWidgetPrivate::get(viewport)->clipRect();
return (pos.y() - area.top() < autoScrollMargin)
|| (area.bottom() - pos.y() < autoScrollMargin)
|| (pos.x() - area.left() < autoScrollMargin)