aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
authorTadashi G. Takaoka <takaoka@google.com>2012-07-11 15:11:12 +0900
committerTadashi G. Takaoka <takaoka@google.com>2012-07-11 15:38:13 +0900
commit1250cdeab2da2c7f7d9c732a816dbc36e49fd61a (patch)
treec8e654776882e200b007d19fb7f2849ead3ccc7c /java/src
parent9c09fd02eb98ebb938e8033371c7e0d4c5ce2f52 (diff)
downloadlatinime-1250cdeab2da2c7f7d9c732a816dbc36e49fd61a.tar.gz
latinime-1250cdeab2da2c7f7d9c732a816dbc36e49fd61a.tar.xz
latinime-1250cdeab2da2c7f7d9c732a816dbc36e49fd61a.zip
Workaround to avoid a bug in the batch input bigram dictionary lookup
Change-Id: I8a5641c88c45918d6bed81a0b03efdcff0b380c5
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/inputmethod/latin/BinaryDictionary.java12
1 files changed, 8 insertions, 4 deletions
diff --git a/java/src/com/android/inputmethod/latin/BinaryDictionary.java b/java/src/com/android/inputmethod/latin/BinaryDictionary.java
index 255ef3ad1..8ab047c67 100644
--- a/java/src/com/android/inputmethod/latin/BinaryDictionary.java
+++ b/java/src/com/android/inputmethod/latin/BinaryDictionary.java
@@ -111,9 +111,14 @@ public class BinaryDictionary extends Dictionary {
Arrays.fill(mInputCodes, WordComposer.NOT_A_CODE);
Arrays.fill(mOutputChars, (char) 0);
Arrays.fill(mOutputScores, 0);
+ final boolean isGesture = composer.isBatchMode();
+ final boolean isValidPrevWord = (prevWord == null)
+ // TODO: Remove this check. Unfortunately the current gesture recognition code has
+ // a double-free bug.
+ && !isGesture;
// TODO: toLowerCase in the native code
- final int[] prevWordCodePointArray = (null == prevWord)
- ? null : StringUtils.toCodePointArray(prevWord.toString());
+ final int[] prevWordCodePointArray = isValidPrevWord
+ ? StringUtils.toCodePointArray(prevWord.toString()) : null;
final int composerSize = composer.size();
if (composerSize <= 1 || !composer.isBatchMode()) {
@@ -124,7 +129,7 @@ public class BinaryDictionary extends Dictionary {
}
final int count;
- if (!composer.isBatchMode() && composer.size() <= 1) {
+ if (!isGesture && composer.size() <= 1) {
if (TextUtils.isEmpty(prevWord)) return null;
int tmpCount = getBigramsNative(mNativeDict, prevWordCodePointArray,
prevWordCodePointArray.length, mInputCodes, composerSize,
@@ -132,7 +137,6 @@ public class BinaryDictionary extends Dictionary {
count = Math.min(tmpCount, MAX_BIGRAMS);
} else {
final InputPointers ips = composer.getInputPointers();
- final boolean isGesture = composer.isBatchMode();
final int codesSize;
if (isGesture) {
codesSize = ips.getPointerSize();