Merge "Fix monkey NullPointerException"

This commit is contained in:
George Mount
2011-10-05 15:33:46 -07:00
committed by Android (Google) Code Review
2 changed files with 14 additions and 1 deletions

View File

@@ -768,9 +768,13 @@ import junit.framework.Assert;
imm.hideSoftInputFromWindow(getWindowToken(), 0); imm.hideSoftInputFromWindow(getWindowToken(), 0);
} }
mInsideRemove = true; mInsideRemove = true;
boolean isFocused = hasFocus();
mWebView.removeView(this); mWebView.removeView(this);
mWebView.requestFocus(); if (isFocused) {
mWebView.requestFocus();
}
mInsideRemove = false; mInsideRemove = false;
mHandler.removeCallbacksAndMessages(null);
} }
@Override @Override

View File

@@ -1581,6 +1581,11 @@ public class WebView extends AbsoluteLayout
mListBoxDialog.dismiss(); mListBoxDialog.dismiss();
mListBoxDialog = null; mListBoxDialog = null;
} }
// remove so that it doesn't cause events
if (mWebTextView != null) {
mWebTextView.remove();
mWebTextView = null;
}
if (mNativeClass != 0) nativeStopGL(); if (mNativeClass != 0) nativeStopGL();
if (mWebViewCore != null) { if (mWebViewCore != null) {
// Set the handlers to null before destroying WebViewCore so no // Set the handlers to null before destroying WebViewCore so no
@@ -7636,6 +7641,10 @@ public class WebView extends AbsoluteLayout
} }
/* package */ void passToJavaScript(String currentText, KeyEvent event) { /* package */ void passToJavaScript(String currentText, KeyEvent event) {
// check if mWebViewCore has been destroyed
if (mWebViewCore == null) {
return;
}
WebViewCore.JSKeyData arg = new WebViewCore.JSKeyData(); WebViewCore.JSKeyData arg = new WebViewCore.JSKeyData();
arg.mEvent = event; arg.mEvent = event;
arg.mCurrentText = currentText; arg.mCurrentText = currentText;