From 6cddd0e8cf539fe5efa36d2b7429e6baaffaa809 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Mon, 2 Dec 2019 13:33:30 +0100 Subject: [PATCH] iOS: Guard against request for textInputView without focus window MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I7b8df07fffef1cc948f6720685234540a20ccc81 Fixes: QTBUG-79316 Reviewed-by: Timur Pocheptsov (cherry picked from commit 9ac156c90b92a981f70929e081c64083b14e9a57) Reviewed-by: Tor Arne Vestbø --- src/plugins/platforms/ios/qiostextresponder.mm | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/plugins/platforms/ios/qiostextresponder.mm b/src/plugins/platforms/ios/qiostextresponder.mm index 396c769be80..1bc97445282 100644 --- a/src/plugins/platforms/ios/qiostextresponder.mm +++ b/src/plugins/platforms/ios/qiostextresponder.mm @@ -781,12 +781,16 @@ - (UIView *)textInputView { + auto *focusWindow = QGuiApplication::focusWindow(); + if (!focusWindow) + return nil; + // iOS expects rects we return from other UITextInput methods // to be relative to the view this method returns. // Since QInputMethod returns rects relative to the top level // QWindow, that is also the view we need to return. - Q_ASSERT(qApp->focusWindow()->handle()); - QPlatformWindow *topLevel = qApp->focusWindow()->handle(); + Q_ASSERT(focusWindow->handle()); + QPlatformWindow *topLevel = focusWindow->handle(); while (QPlatformWindow *p = topLevel->parent()) topLevel = p; return reinterpret_cast(topLevel->winId());