Skip to content
Snippets Groups Projects
Commit 42de819a authored by Jean Chalard's avatar Jean Chalard Committed by Android Git Automerger
Browse files

am 1875860d: Stopgap solution for a crash.

* commit '1875860d':
  Stopgap solution for a crash.
parents d869e1fd 1875860d
No related branches found
No related tags found
No related merge requests found
......@@ -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);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment