Merge "Fix unusual NPE after onDestroy"

main
Tadashi G. Takaoka 2013-11-15 09:03:50 +00:00 committed by Android (Google) Code Review
commit 2cbcc987ee
1 changed files with 4 additions and 5 deletions

View File

@ -722,8 +722,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
LatinImeLogger.commit(); LatinImeLogger.commit();
LatinImeLogger.onDestroy(); LatinImeLogger.onDestroy();
if (mInputUpdater != null) { if (mInputUpdater != null) {
mInputUpdater.onDestroy(); mInputUpdater.quitLooper();
mInputUpdater = null;
} }
super.onDestroy(); super.onDestroy();
} }
@ -1806,13 +1805,13 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
mWordComposer.setCapitalizedModeAtStartComposingTime(getActualCapsMode()); mWordComposer.setCapitalizedModeAtStartComposingTime(getActualCapsMode());
} }
private static final class InputUpdater implements Handler.Callback { static final class InputUpdater implements Handler.Callback {
private final Handler mHandler; private final Handler mHandler;
private final LatinIME mLatinIme; private final LatinIME mLatinIme;
private final Object mLock = new Object(); private final Object mLock = new Object();
private boolean mInBatchInput; // synchronized using {@link #mLock}. private boolean mInBatchInput; // synchronized using {@link #mLock}.
private InputUpdater(final LatinIME latinIme) { InputUpdater(final LatinIME latinIme) {
final HandlerThread handlerThread = new HandlerThread( final HandlerThread handlerThread = new HandlerThread(
InputUpdater.class.getSimpleName()); InputUpdater.class.getSimpleName());
handlerThread.start(); handlerThread.start();
@ -1929,7 +1928,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
.sendToTarget(); .sendToTarget();
} }
private void onDestroy() { void quitLooper() {
mHandler.removeMessages(MSG_GET_SUGGESTED_WORDS); mHandler.removeMessages(MSG_GET_SUGGESTED_WORDS);
mHandler.removeMessages(MSG_UPDATE_GESTURE_PREVIEW_AND_SUGGESTION_STRIP); mHandler.removeMessages(MSG_UPDATE_GESTURE_PREVIEW_AND_SUGGESTION_STRIP);
mHandler.getLooper().quit(); mHandler.getLooper().quit();