Bug 834414 - Fix leaks caused by missing tab change listener unregistrations. r=sriram

This commit is contained in:
Kartikaya Gupta 2013-01-25 13:51:41 -05:00
parent 6b04dce1cc
commit 57216f4b09
5 changed files with 12 additions and 4 deletions

View File

@ -232,6 +232,8 @@ abstract public class BrowserApp extends GeckoApp
super.onDestroy();
if (mAboutHomeContent != null)
mAboutHomeContent.onDestroy();
if (mBrowserToolbar != null)
mBrowserToolbar.onDestroy();
unregisterEventListener("CharEncoding:Data");
unregisterEventListener("CharEncoding:State");

View File

@ -1161,10 +1161,8 @@ public class BrowserToolbar implements ViewSwitcher.ViewFactory,
}
}
public void destroy() {
// The action-items views are reused on rotation.
// Remove them from their parent, so they can be re-attached to new parent.
mActionItemBar.removeAllViews();
public void onDestroy() {
Tabs.unregisterOnTabsChangedListener(this);
}
public boolean openOptionsMenu() {

View File

@ -183,6 +183,7 @@ public class LayerRenderer implements Tabs.OnTabsChangedListener {
if (mFrameRateLayer != null) {
mFrameRateLayer.destroy();
}
Tabs.unregisterOnTabsChangedListener(this);
}
void onSurfaceCreated(EGLConfig config) {

View File

@ -123,6 +123,9 @@ public class LayerView extends FrameLayout {
if (mRenderer != null) {
mRenderer.destroy();
}
if (mTouchEventHandler != null) {
mTouchEventHandler.destroy();
}
}
@Override

View File

@ -141,6 +141,10 @@ public final class TouchEventHandler implements Tabs.OnTabsChangedListener {
Tabs.registerOnTabsChangedListener(this);
}
void destroy() {
Tabs.unregisterOnTabsChangedListener(this);
}
/* This function MUST be called on the UI thread */
public boolean handleEvent(MotionEvent event) {
// if we don't have gecko listeners, just dispatch the event