diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp
index 45b98e9475..61ed9e8bf7 100644
--- a/src/widgets/kernel/qapplication.cpp
+++ b/src/widgets/kernel/qapplication.cpp
@@ -2594,11 +2594,13 @@ QWidget *QApplicationPrivate::pickMouseReceiver(QWidget *candidate, const QPoint
                                                 Qt::MouseButtons buttons, QWidget *buttonDown,
                                                 QWidget *alienWidget)
 {
+    qDebug() << __FUNCTION__ << "candidate=" << candidate;
     Q_ASSERT(candidate);
 
     QWidget *mouseGrabber = QWidget::mouseGrabber();
     if (((type == QEvent::MouseMove && buttons) || (type == QEvent::MouseButtonRelease))
             && !buttonDown && !mouseGrabber) {
+        qDebug() << __FUNCTION__ << "bailout buttonDown=0";
         return 0;
     }
 
@@ -2630,6 +2632,9 @@ bool QApplicationPrivate::sendMouseEvent(QWidget *receiver, QMouseEvent *event,
                                          QWidget **buttonDown, QPointer<QWidget> &lastMouseReceiver,
                                          bool spontaneous, bool onlyDispatchEnterLeave)
 {
+    qDebug() << __FUNCTION__ <<  receiver << event
+     << "alienWidget=" << alienWidget << "nativeWidget=" << nativeWidget << "spontaneous="
+     <<  spontaneous << "onlyDispatchEnterLeave=" << onlyDispatchEnterLeave;
     Q_ASSERT(receiver);
     Q_ASSERT(event);
     Q_ASSERT(nativeWidget);
@@ -2659,8 +2664,10 @@ bool QApplicationPrivate::sendMouseEvent(QWidget *receiver, QMouseEvent *event,
             // after the last button is released.
             if ((alienWidget || !receiver->internalWinId()) && !leaveAfterRelease && !QWidget::mouseGrabber())
                 leaveAfterRelease = *buttonDown;
-            if (event->type() == QEvent::MouseButtonRelease && !event->buttons())
+            if (event->type() == QEvent::MouseButtonRelease && !event->buttons()) {
+                 qDebug() << __FUNCTION__ << "clearing qt_button_down via ptr";
                 *buttonDown = 0;
+            }
         }
     } else if (lastMouseReceiver && widgetUnderMouse) {
         // Dispatch enter/leave if we move:
@@ -3803,6 +3810,7 @@ void QApplicationPrivate::closePopup(QWidget *popup)
     popupWidgets->removeAll(popup);
 
      if (popup == qt_popup_down) {
+         qDebug() << __FUNCTION__ << "clearing qt_button_down";
          qt_button_down = 0;
          qt_popup_down = 0;
      }
diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp
index 6753c35cfc..71bd637527 100644
--- a/src/widgets/kernel/qwidget.cpp
+++ b/src/widgets/kernel/qwidget.cpp
@@ -2486,6 +2486,7 @@ void QWidgetPrivate::deactivateWidgetCleanup()
     if (QApplication::activeWindow() == q)
         QApplication::setActiveWindow(0);
     // If the is the active mouse press widget, reset it
+    qDebug() << __FUNCTION__ << "clearing qt_button_down";
     if (q == qt_button_down)
         qt_button_down = 0;
 }
diff --git a/src/widgets/kernel/qwidgetwindow.cpp b/src/widgets/kernel/qwidgetwindow.cpp
index 7292c795b8..2734dd77ce 100644
--- a/src/widgets/kernel/qwidgetwindow.cpp
+++ b/src/widgets/kernel/qwidgetwindow.cpp
@@ -360,6 +360,7 @@ bool QWidgetWindow::event(QEvent *event)
 #endif // QT_NO_CONTEXTMENU
 
     case QEvent::WindowBlocked:
+        qDebug() << __FUNCTION__ << "WindowBlocked/clearing qt_button_down";
         qt_button_down = 0;
         break;
 
@@ -487,6 +488,9 @@ void QWidgetWindow::handleNonClientAreaMouseEvent(QMouseEvent *e)
 
 void QWidgetWindow::handleMouseEvent(QMouseEvent *event)
 {
+    qDebug() << __FUNCTION__ << event
+             << "qt_button_down=" << qt_button_down
+             << "qt_last_mouse_receive=" << qt_last_mouse_receiver;
     static const QEvent::Type contextMenuTrigger =
         QGuiApplicationPrivate::platformTheme()->themeHint(QPlatformTheme::ContextMenuOnMouseRelease).toBool() ?
         QEvent::MouseButtonRelease : QEvent::MouseButtonPress;
@@ -499,6 +503,7 @@ void QWidgetWindow::handleMouseEvent(QMouseEvent *event)
         QWidget *popupChild  = activePopupWidget->childAt(mapped);
 
         if (activePopupWidget != qt_popup_down) {
+            qDebug() << __FUNCTION__ << "clearing qt_button_down";
             qt_button_down = 0;
             qt_popup_down = 0;
         }
@@ -506,10 +511,12 @@ void QWidgetWindow::handleMouseEvent(QMouseEvent *event)
         switch (event->type()) {
         case QEvent::MouseButtonPress:
         case QEvent::MouseButtonDblClick:
+            qDebug() << __FUNCTION__ << "assigning qt_button_down from popupChild=" << popupChild;
             qt_button_down = popupChild;
             qt_popup_down = activePopupWidget;
             break;
         case QEvent::MouseButtonRelease:
+            qDebug() << __FUNCTION__ << "setting releaseAfter" << event;
             releaseAfter = true;
             break;
         default:
@@ -555,6 +562,7 @@ void QWidgetWindow::handleMouseEvent(QMouseEvent *event)
                 QMouseEvent e(event->type(), widgetPos, event->windowPos(), event->screenPos(),
                               event->button(), event->buttons(), event->modifiers(), event->source());
                 e.setTimestamp(event->timestamp());
+                qDebug() << __FUNCTION__ << "sending1" << receiver << &e;
                 QApplicationPrivate::sendMouseEvent(receiver, &e, receiver, receiver->window(), &qt_button_down, qt_last_mouse_receiver);
                 qt_last_mouse_receiver = receiver;
             }
@@ -574,8 +582,10 @@ void QWidgetWindow::handleMouseEvent(QMouseEvent *event)
         if (qApp->activePopupWidget() != activePopupWidget
             && qt_replay_popup_mouse_event
             && QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::ReplayMousePressOutsidePopup).toBool()) {
-            if (m_widget->windowType() != Qt::Popup)
+            if (m_widget->windowType() != Qt::Popup) {
+                qDebug() << __FUNCTION__ << "clearing qt_button_down";
                 qt_button_down = 0;
+            }
             if (event->type() == QEvent::MouseButtonPress) {
                 // the popup disappeared, replay the mouse press event
                 QWidget *w = QApplication::widgetAt(event->globalPos());
@@ -625,6 +635,7 @@ void QWidgetWindow::handleMouseEvent(QMouseEvent *event)
 #endif
 
         if (releaseAfter) {
+            qDebug() << __FUNCTION__ << "clearing qt_button_down due releaseAfter";
             qt_button_down = 0;
             qt_popup_down = 0;
         }
@@ -642,11 +653,14 @@ void QWidgetWindow::handleMouseEvent(QMouseEvent *event)
     if (!widget)
         widget = m_widget;
 
-    if (event->type() == QEvent::MouseButtonPress)
+    if (event->type() == QEvent::MouseButtonPress) {
         qt_button_down = widget;
+        qDebug() << __FUNCTION__ << "assigning qt_button_down=" << qt_button_down << event;
+    }
 
     QWidget *receiver = QApplicationPrivate::pickMouseReceiver(m_widget, event->windowPos().toPoint(), &mapped, event->type(), event->buttons(),
                                                                qt_button_down, widget);
+    qDebug() << __FUNCTION__ << "receiver=" << receiver ;
     if (!receiver)
         return;
 
@@ -658,6 +672,7 @@ void QWidgetWindow::handleMouseEvent(QMouseEvent *event)
         QMouseEvent translated(event->type(), mapped, event->windowPos(), event->screenPos(),
                                event->button(), event->buttons(), event->modifiers(), event->source());
         translated.setTimestamp(event->timestamp());
+        qDebug() << __FUNCTION__ << "sending2" << receiver << &translated;
         QApplicationPrivate::sendMouseEvent(receiver, &translated, widget, m_widget,
                                             &qt_button_down, qt_last_mouse_receiver);
         event->setAccepted(translated.isAccepted());
