diff options
-rw-r--r-- | src/corelib/kernel/qcoreevent.h | 1 | ||||
-rw-r--r-- | src/widgets/kernel/qwidgetwindow.cpp | 10 |
2 files changed, 7 insertions, 4 deletions
diff --git a/src/corelib/kernel/qcoreevent.h b/src/corelib/kernel/qcoreevent.h index 3ee0eaaa61..8b58fdf55f 100644 --- a/src/corelib/kernel/qcoreevent.h +++ b/src/corelib/kernel/qcoreevent.h @@ -323,6 +323,7 @@ private: friend class QGraphicsViewPrivate; friend class QGraphicsScene; friend class QGraphicsScenePrivate; + friend class QWidgetWindow; #ifndef QT_NO_GESTURES friend class QGestureManager; #endif diff --git a/src/widgets/kernel/qwidgetwindow.cpp b/src/widgets/kernel/qwidgetwindow.cpp index 0031d8e965..fc328e7af0 100644 --- a/src/widgets/kernel/qwidgetwindow.cpp +++ b/src/widgets/kernel/qwidgetwindow.cpp @@ -440,11 +440,13 @@ void QWidgetWindow::handleMouseEvent(QMouseEvent *event) if (!win) win = w->nativeParentWidget()->windowHandle(); if (win && win->geometry().contains(event->globalPos())) { + // Use postEvent() to ensure the local QEventLoop terminates when called from QMenu::exec() const QPoint localPos = win->mapFromGlobal(event->globalPos()); - QMouseEvent e(QEvent::MouseButtonPress, localPos, localPos, event->globalPos(), event->button(), event->buttons(), event->modifiers()); - QGuiApplicationPrivate::setMouseEventSource(&e, QGuiApplicationPrivate::mouseEventSource(event)); - e.setTimestamp(event->timestamp()); - QApplication::sendSpontaneousEvent(win, &e); + QMouseEvent *e = new QMouseEvent(QEvent::MouseButtonPress, localPos, localPos, event->globalPos(), event->button(), event->buttons(), event->modifiers()); + e->spont = 1; + QGuiApplicationPrivate::setMouseEventSource(e, QGuiApplicationPrivate::mouseEventSource(event)); + e->setTimestamp(event->timestamp()); + QCoreApplication::postEvent(win, e); } } } |