tst_QGraphicsItem: properly init QGraphicsSceneDragDropEvent
Nothing was setting its proposedAction() and dropAction(), but they were read in QGraphicsScenePrivate::cloneDragDropEvent(), leading UBSan to complain about reading an invalid value for that enum. Interestingly, Valgrind didn't find this issue, probably because of the strong security options we're now activating by default for a Qt build (stack protector, trivial-auto-var init, ...). Says UBSan (excerpt): qgraphicssceneevent.cpp:1591:15: runtime error: load of value 3200171710, which is not a valid value for type 'DropAction' To fix, explicitly set the two properties on the locally-created QGraphicsSceneDragDropEvent. I didn't go the way of "fixing" this by initializing the members in QGraphicsScenePrivate, because the rest of the test doesn't trigger any other error, so Qt itself is well-behaved, and proactively initializing stuff prevent tools from noticing inconsistencies. Amends the start of the public history. Pick-to: 6.8 6.5 5.15 Change-Id: Ibc9663e8afcd1f7ff9d0e3c646f70e0ceded67a9 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> (cherry picked from commit c0dbfe6c8776fb2f8ca1d7051a605329a9764b83) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
15b3d364ae
commit
ba9d8cc422
@ -11631,6 +11631,8 @@ void tst_QGraphicsItem::itemDiesDuringDraggingOperation()
|
||||
QCoreApplication::sendEvent(&scene, &dragEnter);
|
||||
QGraphicsSceneDragDropEvent event(QEvent::GraphicsSceneDragMove);
|
||||
event.setScenePos(item->boundingRect().center());
|
||||
event.setProposedAction(Qt::DropAction::CopyAction); // prevent uninit'ed copy in...
|
||||
event.setDropAction(Qt::DropAction::CopyAction); // ...QGraphicsScenePrivate::cloneDragDropEvent()
|
||||
QCoreApplication::sendEvent(&scene, &event);
|
||||
QCOMPARE(QGraphicsScenePrivate::get(&scene)->dragDropItem, item);
|
||||
delete item;
|
||||
|
Loading…
x
Reference in New Issue
Block a user