From a704c8a341416ea8e249eb9992777eff55148b00 Mon Sep 17 00:00:00 2001 From: Jarkko Koivikko Date: Tue, 8 Jun 2021 15:31:24 +0300 Subject: plugins/openwnn: reset() should not modify pre-edit text Per contract, the reset() function should not modify pre-edit text. This method is called by the input engine when the input method needs to be reset. The input method must reset its internal state only. The main difference to the update() method is that reset() modifies only the input method state, i.e. it must not modify the input context. Fix by clearing the internal state to avoid modifying pre-edit text. Task-number: QTBUG-94017 Change-Id: I4482188bbe18292d3ef1721e529f09c6054baa5d Reviewed-by: Jarkko Koivikko (cherry picked from commit b9c70451ec5cb08bc9f823d4c3cf240a4f9931b1) Reviewed-by: Qt Cherry-pick Bot --- src/plugins/openwnn/plugin/openwnninputmethod.cpp | 6 ++++-- tests/auto/inputpanel/data/tst_inputpanel.qml | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/plugins/openwnn/plugin/openwnninputmethod.cpp b/src/plugins/openwnn/plugin/openwnninputmethod.cpp index 52405dca..cedebb29 100644 --- a/src/plugins/openwnn/plugin/openwnninputmethod.cpp +++ b/src/plugins/openwnn/plugin/openwnninputmethod.cpp @@ -814,7 +814,7 @@ void OpenWnnInputMethod::selectionListItemSelected(QVirtualKeyboardSelectionList void OpenWnnInputMethod::reset() { Q_D(OpenWnnInputMethod); - d->commitAll(); + d->composingText.clear(); d->initializeScreen(); d->fitInputType(); } @@ -822,8 +822,10 @@ void OpenWnnInputMethod::reset() void OpenWnnInputMethod::update() { Q_D(OpenWnnInputMethod); - if (!d->disableUpdate) + if (!d->disableUpdate) { + d->commitAll(); reset(); + } } } // namespace QtVirtualKeyboard diff --git a/tests/auto/inputpanel/data/tst_inputpanel.qml b/tests/auto/inputpanel/data/tst_inputpanel.qml index e8ea08d8..fc129e21 100644 --- a/tests/auto/inputpanel/data/tst_inputpanel.qml +++ b/tests/auto/inputpanel/data/tst_inputpanel.qml @@ -324,6 +324,7 @@ Rectangle { function test_hardKeyBackspaceClearsInput_data() { return [ { initLocale: "en_GB", initText: "12345", initCursorPosition: 1, inputSequence: "hello", outputText: "12345", expectedCursorPosition: 1 }, + { initLocale: "ja_JP", initText: "12345", initCursorPosition: 1, inputSequence: "watashi", outputText: "12345", expectedCursorPosition: 1 }, ] } -- cgit v1.2.3