Skip to content

Commit

Permalink
3rdparty/openwnn: Fix crash related to entering a smiley
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Mitch Curtis <[email protected]>
  • Loading branch information
jarkkokoivikko-code-q committed Aug 2, 2017
1 parent 4453303 commit c2b877c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/virtualkeyboard/openwnninputmethod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions tests/auto/inputpanel/data/tst_inputpanel.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c2b877c

Please sign in to comment.