macOS: Check m_platformWindow before processing key event after shortcut

Processing shortcut events may result in the window being deleted, so
we need to check if m_platformWindow is still valid before continuing
with the key press event.

Fixes: QTBUG-105160
Change-Id: I9cd362873b19c078a4fced3ac3c815d70bfc7fbe
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
(cherry picked from commit 6a5cadb9557ebac00b8ddacf623dc38baa716680)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Timur Pocheptsov 2022-08-05 13:44:34 +02:00 committed by Qt Cherry-pick Bot
parent 33bc1a80d1
commit bb07d03e2a

View File

@ -32,7 +32,7 @@
}
}
QObject *focusObject = m_platformWindow->window()->focusObject();
QObject *focusObject = m_platformWindow ? m_platformWindow->window()->focusObject() : nullptr;
if (m_sendKeyEvent && focusObject) {
if (auto queryResult = queryInputMethod(focusObject, Qt::ImHints)) {
auto hints = static_cast<Qt::InputMethodHints>(queryResult.value(Qt::ImHints).toUInt());