-
Bug
-
Resolution: Unresolved
-
P1: Critical
-
None
-
6.8.0, 6.8.3, 6.9.1
-
None
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.