diff options
author | 2013-10-22 19:22:57 +0900 | |
---|---|---|
committer | 2013-10-22 05:23:48 -0700 | |
commit | 8a1675379e03bd7830d35212fd987346927068a9 (patch) | |
tree | db8ab6baedd17d78226f2e192102daaeed86654d /java/src | |
parent | 5b5ed3d6092ea539d8cfebd786c63ec0c784040b (diff) | |
download | latinime-8a1675379e03bd7830d35212fd987346927068a9.tar.gz latinime-8a1675379e03bd7830d35212fd987346927068a9.tar.xz latinime-8a1675379e03bd7830d35212fd987346927068a9.zip |
Stopgap solution for a crash.
This returns the wrong string, but since it's used for getting the
previous word for bigrams, it only results in slightly worse
suggestions quality.
Bug: 11273655
Change-Id: I6ce5de2f76effc453ca691a654ab6bf17445b9e7
Diffstat (limited to 'java/src')
-rw-r--r-- | java/src/com/android/inputmethod/latin/RichInputConnection.java | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/java/src/com/android/inputmethod/latin/RichInputConnection.java b/java/src/com/android/inputmethod/latin/RichInputConnection.java index e43cab5ca..c212f9c81 100644 --- a/java/src/com/android/inputmethod/latin/RichInputConnection.java +++ b/java/src/com/android/inputmethod/latin/RichInputConnection.java @@ -294,7 +294,14 @@ public final class RichInputConnection { // the text field, then we can return the cached version right away. if (cachedLength >= n || cachedLength >= mExpectedCursorPosition) { final StringBuilder s = new StringBuilder(mCommittedTextBeforeComposingText); - s.append(mComposingText); + // We call #toString() here to create a temporary object. + // In some situations, this method is called on a worker thread, and it's possible + // the main thread touches the contents of mComposingText while this worker thread + // is suspended, because mComposingText is a StringBuilder. This may lead to crashes, + // so we call #toString() on it. That will result in the return value being strictly + // speaking wrong, but since this is used for basing bigram probability off, and + // it's only going to matter for one getSuggestions call, it's fine in the practice. + s.append(mComposingText.toString()); if (s.length() > n) { s.delete(0, s.length() - n); } |