From 79e14f6c694c8c36dfea84c3962c3f0d476c8d8e Mon Sep 17 00:00:00 2001 From: Jarkko Koivikko <jarkko.koivikko@code-q.fi> Date: Thu, 5 Aug 2021 12:52:15 +0300 Subject: [PATCH] pinyin: Prevent crash when pinyin dictionary cannot be loaded In case the pinyin (system) dictionary cannot be found, the pinyin engine is nullptr. This can lead to a crash when update() is called. Prevent the crash by adding a nullptr check. Fixes: QTBUG-68412 Pick-to: 5.15 6.1 6.2 Change-Id: I04a13ff3abe4aef4a6edd2986aa943fc6d3d995d Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> --- src/plugins/pinyin/plugin/pinyininputmethod.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/pinyin/plugin/pinyininputmethod.cpp b/src/plugins/pinyin/plugin/pinyininputmethod.cpp index 4215ab51..975ce9cf 100644 --- a/src/plugins/pinyin/plugin/pinyininputmethod.cpp +++ b/src/plugins/pinyin/plugin/pinyininputmethod.cpp @@ -73,7 +73,7 @@ public: QVirtualKeyboardInputContext *inputContext = q->inputContext(); // Disable the user dictionary when entering sensitive data - if (inputContext) { + if (inputContext && pinyinDecoderService) { bool userDictionaryEnabled = !inputContext->inputMethodHints().testFlag(Qt::ImhSensitiveData); if (userDictionaryEnabled != pinyinDecoderService->isUserDictionaryEnabled()) pinyinDecoderService->setUserDictionary(userDictionaryEnabled); -- GitLab