Skip to content

Commit 67f9d32

Browse files
George MountAndroid (Google) Code Review
authored andcommitted
Merge "Fix monkey NullPointerException"
2 parents 1302d32 + 1fa26cb commit 67f9d32

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

core/java/android/webkit/WebTextView.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -768,9 +768,13 @@ public boolean performLongClick() {
768768
imm.hideSoftInputFromWindow(getWindowToken(), 0);
769769
}
770770
mInsideRemove = true;
771+
boolean isFocused = hasFocus();
771772
mWebView.removeView(this);
772-
mWebView.requestFocus();
773+
if (isFocused) {
774+
mWebView.requestFocus();
775+
}
773776
mInsideRemove = false;
777+
mHandler.removeCallbacksAndMessages(null);
774778
}
775779

776780
@Override

core/java/android/webkit/WebView.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1581,6 +1581,11 @@ private void destroyImpl() {
15811581
mListBoxDialog.dismiss();
15821582
mListBoxDialog = null;
15831583
}
1584+
// remove so that it doesn't cause events
1585+
if (mWebTextView != null) {
1586+
mWebTextView.remove();
1587+
mWebTextView = null;
1588+
}
15841589
if (mNativeClass != 0) nativeStopGL();
15851590
if (mWebViewCore != null) {
15861591
// Set the handlers to null before destroying WebViewCore so no
@@ -7636,6 +7641,10 @@ public boolean requestChildRectangleOnScreen(View child,
76367641
}
76377642

76387643
/* package */ void passToJavaScript(String currentText, KeyEvent event) {
7644+
// check if mWebViewCore has been destroyed
7645+
if (mWebViewCore == null) {
7646+
return;
7647+
}
76397648
WebViewCore.JSKeyData arg = new WebViewCore.JSKeyData();
76407649
arg.mEvent = event;
76417650
arg.mCurrentText = currentText;

0 commit comments

Comments
 (0)