tst_QDockWidget: hot-fix UB (invalid downcast) in titleBarDoubleClick()
Events of type QEvent::NonClientAreaMouseButtonDblClick have to be QMouseEvent, not just QEvent, as this test function did. Says UBSan: qdockwidget.cpp:1715:36: runtime error: downcast of address 0x7ffea5257d10 which does not point to an object of type 'QMouseEvent' 0x7ffea5257d10: note: object is of type 'QEvent' 3d 7f 00 00 c0 2b dc f4 3d 7f 00 00 b0 00 00 00 01 00 00 00 49 c1 02 3b a1 90 45 7c 20 17 03 00 ^~~~~~~~~~~~~~~~~~~~~~~ vptr for 'QEvent' #0 0x7f3e1bcb0633 in QDockWidget::event(QEvent*) qdockwidget.cpp:1715 #1 0x7f3e1a262351 in QApplicationPrivate::notify_helper(QObject*, QEvent*) qapplication.cpp:3309 #2 0x7f3e1a2e374a in QApplication::notify(QObject*, QEvent*) qapplication.cpp:3259 #3 0x7f3df1e0ca4a in QCoreApplication::notifyInternal2(QObject*, QEvent*) qcoreapplication.cpp:1111 #4 0x7f3df1e0f453 in QCoreApplication::sendEvent(QObject*, QEvent*) qcoreapplication.cpp:1551 #5 0x5599b850aeee in tst_QDockWidget::titleBarDoubleClick() tst_qdockwidget.cpp:869 Fix by creating a minimal QMouseEvent instead. This is a hot-fix to get rid of the UB. I can get away with passing senseless parameters to the QMouseEvent, because the test worked (except for the UB) for even a QEvent. A proper fix should use a proper QMouseEvent. Created QTBUG-135410 to track the issue. Amends the start of the public history, but not picking back. The eventual fix for QTBUG-135410 should first revert this hot-fix, and then pick the proper fix to all then-active branches. Task-number: QTBUG-135410 Change-Id: I188fb5b7d7bdab0432a4877c1948dc0c384a658a Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
This commit is contained in:
parent
43dbbf67ac
commit
0435aaccdc
@ -874,7 +874,8 @@ void tst_QDockWidget::titleBarDoubleClick()
|
||||
win.show();
|
||||
dock.setFloating(true);
|
||||
|
||||
QEvent e(QEvent::NonClientAreaMouseButtonDblClick);
|
||||
QMouseEvent e(QEvent::NonClientAreaMouseButtonDblClick, {}, {}, {}, {}, {}, {}, {},
|
||||
QPointingDevice::primaryPointingDevice());
|
||||
QApplication::sendEvent(&dock, &e);
|
||||
QVERIFY(dock.isFloating());
|
||||
QCOMPARE(win.dockWidgetArea(&dock), Qt::NoDockWidgetArea);
|
||||
|
Loading…
x
Reference in New Issue
Block a user