aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJarkko Koivikko <jarkko.koivikko@code-q.fi>2017-08-02 15:39:48 +0300
committerJarkko Koivikko <jarkko.koivikko@code-q.fi>2017-08-02 14:46:47 +0000
commitc2b877ce613cd0573d66d316b1700d84eff5e1b2 (patch)
treeaad3e7ef995205e50d693b0e37e2223f6db7d13e
parent445330327fd1b909cf53fccc9933896cb1f21248 (diff)
3rdparty/openwnn: Fix crash related to entering a smiley
The crash occurs in Hiragana input mode only when pressing the space after entering a smiley. Fix it by handling the smiley as individual characters instead of text when submitting to OpenWNN engine. [ChangeLog][OpenWNN] Fixed crash when pressing the space after entering a smiley. Task-number: QTBUG-62143 Change-Id: Ic5f271bdfe05491ffd6147f1fc8eb9f54ef4e032 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
-rw-r--r--src/virtualkeyboard/openwnninputmethod.cpp15
-rw-r--r--tests/auto/inputpanel/data/tst_inputpanel.qml2
2 files changed, 12 insertions, 5 deletions
diff --git a/src/virtualkeyboard/openwnninputmethod.cpp b/src/virtualkeyboard/openwnninputmethod.cpp
index 38812f97..edba99c0 100644
--- a/src/virtualkeyboard/openwnninputmethod.cpp
+++ b/src/virtualkeyboard/openwnninputmethod.cpp
@@ -728,15 +728,19 @@ bool OpenWnnInputMethod::keyEvent(Qt::Key key, const QString &text, Qt::Keyboard
default:
if (key < Qt::Key_Escape && !text.isEmpty() && text.at(0).isPrint()) {
- if (d->composingText.size(ComposingText::LAYER1) < OpenWnnInputMethodPrivate::MAX_COMPOSING_TEXT) {
+ if (d->composingText.size(ComposingText::LAYER1) + text.size() > OpenWnnInputMethodPrivate::MAX_COMPOSING_TEXT)
+ return true;
+ const int last = text.size() - 1;
+ for (int i = 0; i <= last; ++i) {
if (d->isEnableL2Converter()) {
d->commitConvertingText();
- d->composingText.insertStrSegment(ComposingText::LAYER0, ComposingText::LAYER1, text);
+ d->composingText.insertStrSegment(ComposingText::LAYER0, ComposingText::LAYER1, text.mid(i, 1));
if (d->preConverter != NULL)
d->preConverter->convert(d->composingText);
- d->updateViewStatusForPrediction(true, true);
+ if (i == last)
+ d->updateViewStatusForPrediction(true, true);
} else {
- d->composingText.insertStrSegment(ComposingText::LAYER0, ComposingText::LAYER1, text);
+ d->composingText.insertStrSegment(ComposingText::LAYER0, ComposingText::LAYER1, text.mid(i, 1));
QString layer1 = d->composingText.toString(ComposingText::LAYER1);
if (!d->isAlphabetLast(layer1)) {
d->commitText(false);
@@ -745,7 +749,8 @@ bool OpenWnnInputMethod::keyEvent(Qt::Key key, const QString &text, Qt::Keyboard
if (completed) {
d->commitTextWithoutLastAlphabet();
} else {
- d->updateViewStatusForPrediction(true, true);
+ if (i == last)
+ d->updateViewStatusForPrediction(true, true);
}
}
}
diff --git a/tests/auto/inputpanel/data/tst_inputpanel.qml b/tests/auto/inputpanel/data/tst_inputpanel.qml
index 7d83d31d..67796016 100644
--- a/tests/auto/inputpanel/data/tst_inputpanel.qml
+++ b/tests/auto/inputpanel/data/tst_inputpanel.qml
@@ -1045,6 +1045,8 @@ Rectangle {
{ initLocale: "ja_JP", initInputMode: "Hiragana", inputSequence: ["n","i","h","o","n","g","o",Qt.Key_Return], outputText: "\u306B\u307B\u3093\u3054" },
// Hiragana to Kanjie conversion
{ initLocale: "ja_JP", initInputMode: "Hiragana", inputSequence: ["n","i","h","o","n","g","o",Qt.Key_Space,Qt.Key_Return], outputText: "\u65E5\u672C\u8A9E" },
+ // Hiragana to Kanjie conversion plus a smiley
+ { initLocale: "ja_JP", initInputMode: "Hiragana", inputSequence: ["n","i","h","o","n","g","o",0xE000,Qt.Key_Space,Qt.Key_Return,Qt.Key_Return], outputText: "\u65E5\u672C\u8A9E\uFF1A\u30FC\uFF09" },
// Correction to Hiragana sequence using exact match mode
{ initLocale: "ja_JP", initInputMode: "Hiragana", inputSequence: [
// Write part of the text leaving out "ni" from the beginning