Use QCoreApplication::postEvent() for replaying popup mouse events.
When replaying the mouse events synchronously, nested calls of QEventLoop::exec() may happen in conjunction with menus. Task-number: QTBUG-38550 Change-Id: I2b1dafdac59d1a080775af5f165d1e594ea58804 Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@digia.com>
This commit is contained in:
parent
9922dafb23
commit
bf9970d40b
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user