Correctly remove WebView from layout before destroying it. throw exception if destroy is called without remove
This commit is contained in:
parent
ee52e00c83
commit
46b1269730
@ -1045,6 +1045,9 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
|
||||
closeActivity();
|
||||
return;
|
||||
} else {
|
||||
if (tabToDelete.getWebView() != null) {
|
||||
mBrowserFrame.removeView(tabToDelete.getWebView());
|
||||
}
|
||||
mTabsManager.deleteTab(position);
|
||||
}
|
||||
final LightningView afterTab = mTabsManager.getCurrentTab();
|
||||
@ -1102,6 +1105,10 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
|
||||
void closeBrowser() {
|
||||
mBrowserFrame.setBackgroundColor(mBackgroundColor);
|
||||
performExitCleanUp();
|
||||
LightningView currentTab = mTabsManager.getCurrentTab();
|
||||
if (currentTab != null && currentTab.getWebView() != null) {
|
||||
mBrowserFrame.removeView(currentTab.getWebView());
|
||||
}
|
||||
mTabsManager.shutdown();
|
||||
mEventBus.post(new BrowserEvents.TabsChanged());
|
||||
finish();
|
||||
|
@ -772,8 +772,7 @@ public class LightningView {
|
||||
// before calling destroy() so that a memory leak is not created
|
||||
ViewGroup parent = (ViewGroup) mWebView.getParent();
|
||||
if (parent != null) {
|
||||
Log.e(Constants.TAG, "WebView was not detached from window before onDestroy");
|
||||
parent.removeView(mWebView);
|
||||
throw new RuntimeException("WebView was not detached from window before onDestroy");
|
||||
}
|
||||
mWebView.stopLoading();
|
||||
mWebView.onPause();
|
||||
|
Loading…
x
Reference in New Issue
Block a user