Fix shortcut overriding.
Moved to processKeyEvents() on all platforms except OS X. Previously QWindowSystemInterface::tryHandleShortcutEvent() was called from inside QWindowSystemInterface, this is considered unsafe as it ends up calling sendEvent(). On some platforms the call might come from a different thread then the receiver and cause an assert. Task-number: QTBUG-44712 Change-Id: Ie80c698f63b9c3d9f52aa94380e539a84caea912 Reviewed-by: Frederik Gladhorn <frederik.gladhorn@theqtcompany.com>
This commit is contained in:
parent
212285639d
commit
7f5b94b473
@ -1859,6 +1859,13 @@ void QGuiApplicationPrivate::processKeyEvent(QWindowSystemInterfacePrivate::KeyE
|
||||
window = QGuiApplication::focusWindow();
|
||||
}
|
||||
|
||||
#if !defined(Q_OS_OSX)
|
||||
// On OS X the shortcut override is checked earlier, see: QWindowSystemInterface::handleKeyEvent()
|
||||
const bool checkShortcut = e->keyType == QEvent::KeyPress && window != 0;
|
||||
if (checkShortcut && QWindowSystemInterface::tryHandleShortcutEvent(window, e->timestamp, e->key, e->modifiers, e->unicode))
|
||||
return;
|
||||
#endif // Q_OS_OSX
|
||||
|
||||
QKeyEvent ev(e->keyType, e->key, e->modifiers,
|
||||
e->nativeScanCode, e->nativeVirtualKey, e->nativeModifiers,
|
||||
e->unicode, e->repeat, e->repeatCount);
|
||||
|
@ -292,8 +292,13 @@ void QWindowSystemInterface::handleKeyEvent(QWindow *w, QEvent::Type t, int k, Q
|
||||
|
||||
void QWindowSystemInterface::handleKeyEvent(QWindow *tlw, ulong timestamp, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text, bool autorep, ushort count)
|
||||
{
|
||||
// This is special handling needed for OS X which eventually will call sendEvent(), on other platforms
|
||||
// this might not be safe, e.g., on Android. See: QGuiApplicationPrivate::processKeyEvent() for
|
||||
// shortcut overriding on other platforms.
|
||||
#if defined(Q_OS_OSX)
|
||||
if (t == QEvent::KeyPress && QWindowSystemInterface::tryHandleShortcutEvent(tlw, timestamp, k, mods, text))
|
||||
return;
|
||||
#endif // Q_OS_OSX
|
||||
|
||||
QWindowSystemInterfacePrivate::KeyEvent * e =
|
||||
new QWindowSystemInterfacePrivate::KeyEvent(tlw, timestamp, t, k, mods, text, autorep, count);
|
||||
@ -318,10 +323,7 @@ void QWindowSystemInterface::handleExtendedKeyEvent(QWindow *tlw, ulong timestam
|
||||
const QString& text, bool autorep,
|
||||
ushort count, bool tryShortcutOverride)
|
||||
{
|
||||
// on OS X we try the shortcut override even earlier and thus shouldn't handle it here
|
||||
if (tryShortcutOverride && type == QEvent::KeyPress && QWindowSystemInterface::tryHandleShortcutEvent(tlw, timestamp, key, modifiers, text))
|
||||
return;
|
||||
|
||||
Q_UNUSED(tryShortcutOverride)
|
||||
QWindowSystemInterfacePrivate::KeyEvent * e =
|
||||
new QWindowSystemInterfacePrivate::KeyEvent(tlw, timestamp, type, key, modifiers,
|
||||
nativeScanCode, nativeVirtualKey, nativeModifiers, text, autorep, count);
|
||||
|
Loading…
Reference in New Issue
Block a user