Bug 834414 - Remove a dangling reference to the LayerView in the IME code when the activity is destroyed. r=jchen

This commit is contained in:
Kartikaya Gupta 2013-01-25 13:51:41 -05:00
parent 85763f1828
commit bfdb4ce5ac
2 changed files with 15 additions and 10 deletions

View File

@ -1569,6 +1569,8 @@ abstract public class GeckoApp
LayerView layerView = (LayerView) findViewById(R.id.layer_view);
layerView.initializeView(GeckoAppShell.getEventDispatcher());
mLayerView = layerView;
// bind the GeckoEditable instance to the new LayerView
GeckoAppShell.notifyIMEEnabled(GeckoEditableListener.IME_STATE_DISABLED, "", "", "", false);
}
}

View File

@ -20,6 +20,7 @@ import android.text.TextPaint;
import android.text.TextUtils;
import android.text.style.CharacterStyle;
import android.util.Log;
import android.view.View;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
@ -77,9 +78,10 @@ final class GeckoEditable
private final SpannableStringBuilder mText;
private final SpannableStringBuilder mChangedText;
private final Editable mProxy;
private final GeckoEditableListener mListener;
private final ActionQueue mActionQueue;
private View mCurrentView;
private GeckoEditableListener mListener;
private int mSavedSelectionStart;
private volatile int mGeckoUpdateSeqno;
private int mUIUpdateSeqno;
@ -256,8 +258,8 @@ final class GeckoEditable
Editable.class.getClassLoader(),
PROXY_INTERFACES, this);
LayerView v = GeckoApp.mAppContext.getLayerView();
mListener = GeckoInputConnection.create(v, this);
mCurrentView = GeckoApp.mAppContext.getLayerView();
mListener = GeckoInputConnection.create(mCurrentView, this);
}
private static void geckoPostToUI(Runnable runnable) {
@ -545,10 +547,8 @@ final class GeckoEditable
@Override
public void notifyIMEEnabled(final int state, final String typeHint,
final String modeHint, final String actionHint) {
if (DEBUG) {
// GeckoEditableListener methods should all be called from the Gecko thread
GeckoApp.assertOnGeckoThread();
}
// Because we want to be able to bind GeckoEditable to the newest LayerView instance,
// this can be called from the Java UI thread in addition to the Gecko thread.
geckoPostToUI(new Runnable() {
public void run() {
// Make sure there are no other things going on
@ -558,10 +558,13 @@ final class GeckoEditable
// InputConnectionHandler.onCreateInputConnection
LayerView v = GeckoApp.mAppContext.getLayerView();
if (v != null) {
v.setInputConnectionHandler((InputConnectionHandler)mListener);
if (v != mCurrentView) {
mCurrentView = v;
mListener = GeckoInputConnection.create(v, GeckoEditable.this);
v.setInputConnectionHandler((InputConnectionHandler)mListener);
}
mListener.notifyIMEEnabled(state, typeHint, modeHint, actionHint);
}
mListener.notifyIMEEnabled(state, typeHint,
modeHint, actionHint);
}
});
}