From e6e2011d34f03a502b848215b851d3d53f7395a4 Mon Sep 17 00:00:00 2001 From: Jim Chen Date: Tue, 30 Aug 2016 14:49:38 -0400 Subject: [PATCH] Bug 1298161 - c. Properly remove pref handler in NativePanZoomController; r=rbarker Properly remove pref handler on destroy to prevent leaking BrowserApp. --- .../java/org/mozilla/gecko/gfx/NativePanZoomController.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/gfx/NativePanZoomController.java b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/gfx/NativePanZoomController.java index 2db0d1ac1619..6d08becde5bf 100644 --- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/gfx/NativePanZoomController.java +++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/gfx/NativePanZoomController.java @@ -29,7 +29,7 @@ class NativePanZoomController extends JNIObject implements PanZoomController { private Overscroll mOverscroll; boolean mNegateWheelScroll; private float mPointerScrollFactor; - private final PrefsHelper.PrefHandler mPrefsObserver; + private PrefsHelper.PrefHandler mPrefsObserver; private long mLastDownTime; private static final float MAX_SCROLL = 0.075f * GeckoAppShell.getDpi(); @@ -197,6 +197,10 @@ class NativePanZoomController extends JNIObject implements PanZoomController { @Override @WrapForJNI(calledFrom = "ui") // PanZoomController public void destroy() { + if (mPrefsObserver != null) { + PrefsHelper.removeObserver(mPrefsObserver); + mPrefsObserver = null; + } if (mDestroyed || !mTarget.isGeckoReady()) { return; }