Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-138405

Segfault in QQuickTextPrivate if no input method set

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P1: Critical P1: Critical
    • None
    • 6.8.0, 6.8.3, 6.9.1
    • Quick: Other
    • None
    • Windows

      QQuickTextPrivate::determineHorizontalAlignment() crashes in if no input method is set.

      #include <QQmlApplicationEngine>
      #include <QQmlComponent>
      #include <QTest>
      
      class InputMethodCrash : public QObject
      {
          Q_OBJECT
      
      private slots:
          void minimalTestCase() {
              auto engine = QQmlApplicationEngine{};
              auto component = QQmlComponent{&engine};
              component.setData("import QtQuick; Text {}", QUrl{});
              QVERIFY2(component.create() != nullptr, qUtf8Printable(component.errorString()));
          }
      };
      
      QTEST_MAIN(InputMethodCrash)
      
      #include "main.moc"
      

      This line is to blame, where QGuiApplication::inputMethod() is used without nullptr check:

              bool alignToRight = text.isEmpty() ? QGuiApplication::inputMethod()->inputDirection() == Qt::RightToLeft : rightToLeftText;
      

       
      Top of backtrace:

      QInputMethod::inputDirection()
      QQuickTextPrivate::determineHorizontalAlignment()
      QQuickTextPrivate::determineHorizontalAlignment()
      QQuickText::componentComplete()
      QQmlObjectCreator::finalize()
      ...
      

      Expected behavior: A warning should be printed (if at all), instead of crashing the app.

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            hasselmann_via_meiller Mathias Hasselmann
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:

                There are no open Gerrit changes