From 7580f4260691ff2f64bbd06afe48bd6d6bd97308 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Mon, 17 Jun 2024 10:49:51 +0200 Subject: [PATCH] iOS: Don't send focus out event when resigning responder without qGuiApp During shutdown of the app the QUIView may hang around longer than the QIOSWindow or QGuiApplication, at which point we can't deliver the resigned responder status to QGuiApp as a focus out event. Fixes: QTBUG-123018 Change-Id: If377f037c3fb4c2026a2d8d757011f12171e8dd4 Reviewed-by: Doris Verria (cherry picked from commit a40d546496462e5366c24115707e43a0c8598dd3) Reviewed-by: Qt Cherry-pick Bot --- src/plugins/platforms/ios/quiview.mm | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/plugins/platforms/ios/quiview.mm b/src/plugins/platforms/ios/quiview.mm index cc4b92b92b2..b31e1a043dc 100644 --- a/src/plugins/platforms/ios/quiview.mm +++ b/src/plugins/platforms/ios/quiview.mm @@ -333,9 +333,11 @@ inline ulong getTimeStamp(UIEvent *event) qImDebug() << self << "resigned first responder"; - UIResponder *newResponder = FirstResponderCandidate::currentCandidate(); - if ([self responderShouldTriggerWindowDeactivation:newResponder]) - QWindowSystemInterface::handleFocusWindowChanged(nullptr, Qt::ActiveWindowFocusReason); + if (qGuiApp) { + UIResponder *newResponder = FirstResponderCandidate::currentCandidate(); + if ([self responderShouldTriggerWindowDeactivation:newResponder]) + QWindowSystemInterface::handleFocusWindowChanged(nullptr, Qt::ActiveWindowFocusReason); + } return YES; }