diff options
authorRichard Moe Gustavsen <>2018-11-06 13:38:09 +0100
committerRichard Moe Gustavsen <>2018-11-07 13:22:21 +0000
commita545b85bdd8d227c63dda07728de4d1bac285cf5 (patch)
parentcfbb0d2b407e45d652d18ecd940adbbc8b3ddddd (diff)
QWidgetWindow: check if receiver is deleted after event delivery
When a popup is active, we set the receiver of mouse events to be the active popup widget. But when we send a mouse event to the popup, the receiver might start a new QEventLoop (e.g by executing a new dialog). And in the meantime, the popup will be destroyed. This will cause a crash in the line after the event delivery (where we sat "qt_last_mouse_receiver = receiver"), since at that point, "receiver" would be a dangling pointer. This patch will use a QPointer instead of a raw pointer to store "receiver", to ensure that it's set to null for such cases. Fixes: QTBUG-71062 Change-Id: Ie017cfa97370513ecfdd62c056fcb0e6c991f9f6 Reviewed-by: Eirik Aavitsland <>
1 files changed, 1 insertions, 1 deletions
diff --git a/src/widgets/kernel/qwidgetwindow.cpp b/src/widgets/kernel/qwidgetwindow.cpp
index 7292c795b8..0b2d72f330 100644
--- a/src/widgets/kernel/qwidgetwindow.cpp
+++ b/src/widgets/kernel/qwidgetwindow.cpp
@@ -521,7 +521,7 @@ void QWidgetWindow::handleMouseEvent(QMouseEvent *event)
if (activePopupWidget->isEnabled()) {
// deliver event
qt_replay_popup_mouse_event = false;
- QWidget *receiver = activePopupWidget;
+ QPointer<QWidget> receiver = activePopupWidget;
QPoint widgetPos = mapped;
if (qt_button_down)
receiver = qt_button_down;