From c3f619069a41f33dcd36a215807c85904ab6c5d2 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Tue, 9 Dec 2014 13:58:24 +0100 Subject: [PATCH] Unbreak shortcut handling on embedded MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It went completely broken after the fix for QTBUG-32928. The crash fix I made afterwards forgot to take into account that the shortcuts must still be handled, even when the window in the input event is null. So instead of bailing out on a null tlw, we have to use the window that currently has the focus. Task-number: QTBUG-43203 Change-Id: I6cd65ee5bd021f80d9440cba8bc9dfda9abe2cfd Reviewed-by: Jørgen Lind --- src/gui/kernel/qwindowsysteminterface.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/gui/kernel/qwindowsysteminterface.cpp b/src/gui/kernel/qwindowsysteminterface.cpp index 236f970c78..a564f507d8 100644 --- a/src/gui/kernel/qwindowsysteminterface.cpp +++ b/src/gui/kernel/qwindowsysteminterface.cpp @@ -201,6 +201,11 @@ bool QWindowSystemInterface::tryHandleShortcutEvent(QWindow *w, ulong timestamp, #ifndef QT_NO_SHORTCUT QGuiApplicationPrivate::modifier_buttons = mods; + if (!w) + w = QGuiApplication::focusWindow(); + if (!w) + return false; + QObject *focus = w->focusObject(); if (!focus) focus = w; @@ -287,8 +292,8 @@ 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) { - if (t == QEvent::KeyPress && tlw && QWindowSystemInterface::tryHandleShortcutEvent(tlw, timestamp, k, mods, text)) - return; + if (t == QEvent::KeyPress && QWindowSystemInterface::tryHandleShortcutEvent(tlw, timestamp, k, mods, text)) + return; QWindowSystemInterfacePrivate::KeyEvent * e = new QWindowSystemInterfacePrivate::KeyEvent(tlw, timestamp, t, k, mods, text, autorep, count); @@ -314,8 +319,8 @@ void QWindowSystemInterface::handleExtendedKeyEvent(QWindow *tlw, ulong timestam ushort count, bool tryShortcutOverride) { // on OS X we try the shortcut override even earlier and thus shouldn't handle it here - if (tryShortcutOverride && tlw && type == QEvent::KeyPress && QWindowSystemInterface::tryHandleShortcutEvent(tlw, timestamp, key, modifiers, text)) - return; + if (tryShortcutOverride && type == QEvent::KeyPress && QWindowSystemInterface::tryHandleShortcutEvent(tlw, timestamp, key, modifiers, text)) + return; QWindowSystemInterfacePrivate::KeyEvent * e = new QWindowSystemInterfacePrivate::KeyEvent(tlw, timestamp, type, key, modifiers,