Be more graceful when objects die by the time the dnd loop exits

The main issue fixed in 7f23dd963536eb8123ee4c5c22bf43b6f866d008 can
manifest in another form on platforms where QBasicDrag is used (xcb).

Make sure that we recognize if an object (e.g. a QWidgetWindow) is
destroyed by the time the nested event loop exits.

Pick-to: 6.4 6.3 6.2
Task-number: QTBUG-104596
Change-Id: Ib82dd8230cb6f13d804bd992234b2a3ce85a7061
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
This commit is contained in:
Laszlo Agocs 2022-07-01 15:20:08 +02:00
parent e671b852e7
commit 742ae9ea1c

View File

@ -124,6 +124,7 @@ bool QBasicDrag::eventFilter(QObject *o, QEvent *e)
}
case QEvent::MouseButtonRelease:
{
QPointer<QObject> objGuard(o);
disableEventFilter();
if (canDrop()) {
QPoint nativePosition = getNativeMousePos(e, m_drag_icon_window);
@ -133,6 +134,8 @@ bool QBasicDrag::eventFilter(QObject *o, QEvent *e)
cancel();
}
exitDndEventLoop();
if (!objGuard)
return true;
// If a QShapedPixmapWindow (drag feedback) is being dragged along, the
// mouse event's localPos() will be relative to that, which is useless.