Browse Source

Correctly remove WebView from layout before destroying it. throw exception if destroy is called without remove

master
Anthony Restaino 9 years ago
parent
commit
46b1269730
  1. 7
      app/src/main/java/acr/browser/lightning/activity/BrowserActivity.java
  2. 3
      app/src/main/java/acr/browser/lightning/view/LightningView.java

7
app/src/main/java/acr/browser/lightning/activity/BrowserActivity.java

@ -1045,6 +1045,9 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements @@ -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 @@ -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();

3
app/src/main/java/acr/browser/lightning/view/LightningView.java

@ -772,8 +772,7 @@ public class LightningView { @@ -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…
Cancel
Save