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 QGraphicsViewPrivate;
|
||||||
friend class QGraphicsScene;
|
friend class QGraphicsScene;
|
||||||
friend class QGraphicsScenePrivate;
|
friend class QGraphicsScenePrivate;
|
||||||
|
friend class QWidgetWindow;
|
||||||
#ifndef QT_NO_GESTURES
|
#ifndef QT_NO_GESTURES
|
||||||
friend class QGestureManager;
|
friend class QGestureManager;
|
||||||
#endif
|
#endif
|
||||||
|
@ -440,11 +440,13 @@ void QWidgetWindow::handleMouseEvent(QMouseEvent *event)
|
|||||||
if (!win)
|
if (!win)
|
||||||
win = w->nativeParentWidget()->windowHandle();
|
win = w->nativeParentWidget()->windowHandle();
|
||||||
if (win && win->geometry().contains(event->globalPos())) {
|
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());
|
const QPoint localPos = win->mapFromGlobal(event->globalPos());
|
||||||
QMouseEvent e(QEvent::MouseButtonPress, localPos, localPos, event->globalPos(), event->button(), event->buttons(), event->modifiers());
|
QMouseEvent *e = new QMouseEvent(QEvent::MouseButtonPress, localPos, localPos, event->globalPos(), event->button(), event->buttons(), event->modifiers());
|
||||||
QGuiApplicationPrivate::setMouseEventSource(&e, QGuiApplicationPrivate::mouseEventSource(event));
|
e->spont = 1;
|
||||||
e.setTimestamp(event->timestamp());
|
QGuiApplicationPrivate::setMouseEventSource(e, QGuiApplicationPrivate::mouseEventSource(event));
|
||||||
QApplication::sendSpontaneousEvent(win, &e);
|
e->setTimestamp(event->timestamp());
|
||||||
|
QCoreApplication::postEvent(win, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user