Bug 774304 - Check for null pref values when closing MultiChoicePreference. r=mfinkle
authorBrian Nicholson <bnicholson@mozilla.com>
Thu, 18 Oct 2012 12:28:27 -0700
changeset 110832 421315a62cb5e098c01610514d3d368d339fabc0
parent 110831 6bcd2ba50e848b5449b52d14ca183f6a4e3c154f
child 110833 907354856a079b8d6ecc65c8f8cc2f33841b84e9
push id93
push usernmatsakis@mozilla.com
push dateWed, 31 Oct 2012 21:26:57 +0000
reviewersmfinkle
bugs774304
milestone19.0a1
Bug 774304 - Check for null pref values when closing MultiChoicePreference. r=mfinkle
mobile/android/base/MultiChoicePreference.java
--- a/mobile/android/base/MultiChoicePreference.java
+++ b/mobile/android/base/MultiChoicePreference.java
@@ -164,16 +164,22 @@ class MultiChoicePreference extends Dial
                 if (button.isEnabled() != enabled)
                     button.setEnabled(enabled);
             }
         });
     }
 
     @Override
     protected void onDialogClosed(boolean positiveResult) {
+        if (mPrevValues == null || mInitialValues == null) {
+            // Initialization is done asynchronously, so these values may not
+            // have been set before the dialog was closed.
+            return;
+        }
+
         if (!positiveResult) {
             // user cancelled; reset checkbox values to their previous state
             mValues = mPrevValues.clone();
             return;
         } else {
             mPrevValues = mValues.clone();
         }