From 0e00f5fe3a00ca13ebf6b59cd04f58b11429fa88 Mon Sep 17 00:00:00 2001 From: Jean Chalard Date: Thu, 20 Nov 2014 13:50:27 +0900 Subject: [PATCH] Fix a NPE Bug: 18451316 Change-Id: Ia20bf388471f84c963354df050182e722d966a02 --- .../android/inputmethod/latin/DictionaryFacilitator.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/java/src/com/android/inputmethod/latin/DictionaryFacilitator.java b/java/src/com/android/inputmethod/latin/DictionaryFacilitator.java index d23639a0d..b24fdea55 100644 --- a/java/src/com/android/inputmethod/latin/DictionaryFacilitator.java +++ b/java/src/com/android/inputmethod/latin/DictionaryFacilitator.java @@ -266,6 +266,12 @@ public class DictionaryFacilitator { } final DictionaryGroup newMostProbableDictionaryGroup = findDictionaryGroupWithLocale(mDictionaryGroups, locale); + if (null == newMostProbableDictionaryGroup) { + // It seems this may happen as a race condition; pressing the globe key and space + // in quick succession could commit a word out of a dictionary that's not in the + // facilitator any more. In this case, just not changing things is fine. + return; + } mMostProbableDictionaryGroup.mWeightForTypingInLocale = DictionaryGroup.WEIGHT_FOR_TYPING_IN_NOT_MOST_PROBABLE_LANGUAGE; mMostProbableDictionaryGroup.mWeightForGesturingInLocale =