[Interest] Qt at iOS: Crash on null QWindow pointer in QIOSInputContext::scrollToCursor

Robert Iakobashvili coroberti at gmail.com
Tue Nov 10 06:49:39 CET 2015


Gentlemen,
My app was crashing on a null QWindow pointer
from focusView() in QIOSInputContext::scrollToCursor

Unfortunately, my attempt to create a reproducing example
failed; thus, a formal bug-report is not an option.

The scenario is:
sending an email from a native popover over a Qt-widget app,
it was crashing on appearance of
Apple's Mail window.

It could be work-arounded by checking the result of
focusView() call prior to using it and not assuming that
it for sure contains a valid QWindow:

--- qiosinputcontext.mm.orig    2015-11-02 14:39:50.000000000 +0200
+++ qiosinputcontext.mm    2015-11-02 14:45:43.000000000 +0200
@@ -456,7 +456,10 @@

     const int margin = 20;
     QRectF translatedCursorPos = qApp->inputMethod()->cursorRectangle();
-
translatedCursorPos.translate(focusView().qwindow->geometry().topLeft());
+    QWindow* qw = focusView().qwindow;
+    if (! qw)
+    return;
+    translatedCursorPos.translate(qw->geometry().topLeft());

     qreal keyboardY = [rootView
convertRect:m_keyboardState.keyboardEndRect fromView:nil].origin.y;
     int statusBarY = qGuiApp->primaryScreen()->availableGeometry().y();


Hope, it helps to somebody.

Take care,

Regards,
Robert
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20151110/3779f10c/attachment.html>


More information about the Interest mailing list