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 <Friedemann.Kleint@qt.io>
This commit is contained in:
parent
9ea9818eeb
commit
3b3b5968d0
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user