Skip to content

Commit 1d22e12

Browse files
Jean-Baptiste QueruAndroid Code Review
authored andcommitted
Merge "Fix a monkey crash when the new WebView is destroyed."
2 parents 55a2df8 + 35e7197 commit 1d22e12

2 files changed

Lines changed: 10 additions & 8 deletions

File tree

core/java/android/webkit/BrowserFrame.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -785,11 +785,7 @@ private void didReceiveTouchIconUrl(String url, boolean precomposed) {
785785
* @return The BrowserFrame object stored in the new WebView.
786786
*/
787787
private BrowserFrame createWindow(boolean dialog, boolean userGesture) {
788-
WebView w = mCallbackProxy.createWindow(dialog, userGesture);
789-
if (w != null) {
790-
return w.getWebViewCore().getBrowserFrame();
791-
}
792-
return null;
788+
return mCallbackProxy.createWindow(dialog, userGesture);
793789
}
794790

795791
/**

core/java/android/webkit/CallbackProxy.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1098,7 +1098,7 @@ public void onProgressChanged(int newProgress) {
10981098
}
10991099
}
11001100

1101-
public WebView createWindow(boolean dialog, boolean userGesture) {
1101+
public BrowserFrame createWindow(boolean dialog, boolean userGesture) {
11021102
// Do an unsynchronized quick check to avoid posting if no callback has
11031103
// been set.
11041104
if (mWebChromeClient == null) {
@@ -1122,9 +1122,15 @@ public WebView createWindow(boolean dialog, boolean userGesture) {
11221122

11231123
WebView w = transport.getWebView();
11241124
if (w != null) {
1125-
w.getWebViewCore().initializeSubwindow();
1125+
WebViewCore core = w.getWebViewCore();
1126+
// If WebView.destroy() has been called, core may be null. Skip
1127+
// initialization in that case and return null.
1128+
if (core != null) {
1129+
core.initializeSubwindow();
1130+
return core.getBrowserFrame();
1131+
}
11261132
}
1127-
return w;
1133+
return null;
11281134
}
11291135

11301136
public void onRequestFocus() {

0 commit comments

Comments
 (0)