Fix monkey NullPointerException

bug: 5385775
 Check mWebViewCore has been destroyed
 Remove mWebTextView from WebView when WebView is destroyed
 Clear WebTextView's handler when it is removed from WebView

Change-Id: I9c62292d693109e692c341e3e4dba3e04af81fe4
This commit is contained in:
George Mount
2011-10-03 10:56:28 -07:00
parent 8ebf1efd66
commit 1fa26cbfc8
2 changed files with 14 additions and 1 deletions

View File

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

View File

@@ -1581,6 +1581,11 @@ public class WebView extends AbsoluteLayout
mListBoxDialog.dismiss();
mListBoxDialog = null;
}
// remove so that it doesn't cause events
if (mWebTextView != null) {
mWebTextView.remove();
mWebTextView = null;
}
if (mNativeClass != 0) nativeStopGL();
if (mWebViewCore != null) {
// 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) {
// check if mWebViewCore has been destroyed
if (mWebViewCore == null) {
return;
}
WebViewCore.JSKeyData arg = new WebViewCore.JSKeyData();
arg.mEvent = event;
arg.mCurrentText = currentText;