Fix: NPE after onDestroy().

Bug: 13671513
Change-Id: I06aa14870ff5422ad514356ee406600b247858c5
main
Keisuke Kuroyanagi 2014-03-28 12:17:44 +09:00
parent 618a949f9d
commit 30cd0cd2a0
2 changed files with 15 additions and 0 deletions

View File

@ -269,6 +269,9 @@ abstract public class ExpandableBinaryDictionary extends Dictionary {
} }
private void runGCAfterAllPrioritizedTasksIfRequiredLocked(final boolean mindsBlockByGC) { private void runGCAfterAllPrioritizedTasksIfRequiredLocked(final boolean mindsBlockByGC) {
if (mBinaryDictionary == null) {
return;
}
// needsToRunGC() have to be called with lock. // needsToRunGC() have to be called with lock.
if (mBinaryDictionary.needsToRunGC(mindsBlockByGC)) { if (mBinaryDictionary.needsToRunGC(mindsBlockByGC)) {
if (setProcessingLargeTaskIfNot()) { if (setProcessingLargeTaskIfNot()) {
@ -357,6 +360,9 @@ abstract public class ExpandableBinaryDictionary extends Dictionary {
public void run() { public void run() {
final boolean locked = setProcessingLargeTaskIfNot(); final boolean locked = setProcessingLargeTaskIfNot();
try { try {
if (mBinaryDictionary == null) {
return;
}
mBinaryDictionary.addMultipleDictionaryEntries( mBinaryDictionary.addMultipleDictionaryEntries(
languageModelParams.toArray( languageModelParams.toArray(
new LanguageModelParam[languageModelParams.size()])); new LanguageModelParam[languageModelParams.size()]));
@ -496,6 +502,9 @@ abstract public class ExpandableBinaryDictionary extends Dictionary {
} }
private void flushDictionaryLocked() { private void flushDictionaryLocked() {
if (mBinaryDictionary == null) {
return;
}
if (mBinaryDictionary.needsToRunGC(false /* mindsBlockByGC */)) { if (mBinaryDictionary.needsToRunGC(false /* mindsBlockByGC */)) {
mBinaryDictionary.flushWithGC(); mBinaryDictionary.flushWithGC();
} else { } else {

View File

@ -110,6 +110,9 @@ public final class LanguageModelParam {
final LanguageModelParam languageModelParam = final LanguageModelParam languageModelParam =
detectWhetherVaildWordOrNotAndGetLanguageModelParam( detectWhetherVaildWordOrNotAndGetLanguageModelParam(
prevWord, tempWord, timestamp, dictionaryFacilitator); prevWord, tempWord, timestamp, dictionaryFacilitator);
if (languageModelParam == null) {
continue;
}
languageModelParams.add(languageModelParam); languageModelParams.add(languageModelParam);
prevWord = languageModelParam.mTargetWord; prevWord = languageModelParam.mTargetWord;
} }
@ -120,6 +123,9 @@ public final class LanguageModelParam {
final String prevWord, final String targetWord, final int timestamp, final String prevWord, final String targetWord, final int timestamp,
final DictionaryFacilitatorForSuggest dictionaryFacilitator) { final DictionaryFacilitatorForSuggest dictionaryFacilitator) {
final Locale locale = dictionaryFacilitator.getLocale(); final Locale locale = dictionaryFacilitator.getLocale();
if (locale == null) {
return null;
}
if (!dictionaryFacilitator.isValidWord(targetWord, true /* ignoreCase */)) { if (!dictionaryFacilitator.isValidWord(targetWord, true /* ignoreCase */)) {
// OOV word. // OOV word.
return createAndGetLanguageModelParamOfWord(prevWord, targetWord, timestamp, return createAndGetLanguageModelParamOfWord(prevWord, targetWord, timestamp,