Bug 1116693 - Block dispatching onItemChanged during MenuItem inflation r=rnewman
authorMark Finkle <mfinkle@mozilla.com>
Wed, 31 Dec 2014 14:47:18 -0500
changeset 221774 f0568ac27834c6246d035fdfdf015224f5079b02
parent 221773 e517f97929b49683fcc3804a9b9820597f33a075
child 221775 677ee53bc06e6b0325fe583f1987012e66d40e1e
push id28041
push userkwierso@gmail.com
push dateThu, 01 Jan 2015 00:53:12 +0000
treeherdermozilla-central@3c296aa11c51 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrnewman
bugs1116693
milestone37.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1116693 - Block dispatching onItemChanged during MenuItem inflation r=rnewman
mobile/android/base/menu/GeckoMenuInflater.java
--- a/mobile/android/base/menu/GeckoMenuInflater.java
+++ b/mobile/android/base/menu/GeckoMenuInflater.java
@@ -151,19 +151,35 @@ public class GeckoMenuInflater extends M
         if (Versions.feature11Plus) {
             item.showAsAction = a.getInt(R.styleable.MenuItem_android_showAsAction, 0);
         }
 
         a.recycle();
     }
 
     public void setValues(ParsedItem item, MenuItem menuItem) {
+        // We are blocking any presenter updates during inflation.
+        GeckoMenuItem geckoItem = null;
+        if (menuItem instanceof GeckoMenuItem) {
+            geckoItem = (GeckoMenuItem) menuItem;
+        }
+
+        if (geckoItem != null) {
+            geckoItem.stopDispatchingChanges();
+        }
+
         menuItem.setChecked(item.checked)
                 .setVisible(item.visible)
                 .setEnabled(item.enabled)
                 .setCheckable(item.checkable)
                 .setIcon(item.iconRes);
 
         if (Versions.feature11Plus) {
             menuItem.setShowAsAction(item.showAsAction);
         }
+
+        if (geckoItem != null) {
+            // We don't need to allow presenter updates during inflation,
+            // so we use the weak form of re-enabling changes.
+            geckoItem.resumeDispatchingChanges();
+        }
     }
 }