Bug 971735 - Remove element using iterator while looping in ArrayList (r=wesj)
authorLucas Rocha <lucasr@mozilla.com>
Mon, 17 Feb 2014 11:07:53 +0000
changeset 169554 7273e402c9e660a33f787a33a5381aebc9d64204
parent 169469 56172f02c23be3cdbfd7fdedab87f9b49bd7b96f
child 169555 0af93d42b8f88fb9867a10b75fdbbce8c803f830
push id270
push userpvanderbeken@mozilla.com
push dateThu, 06 Mar 2014 09:24:21 +0000
reviewerswesj
bugs971735
milestone30.0a1
Bug 971735 - Remove element using iterator while looping in ArrayList (r=wesj)
mobile/android/base/widget/ActivityChooserModel.java
--- a/mobile/android/base/widget/ActivityChooserModel.java
+++ b/mobile/android/base/widget/ActivityChooserModel.java
@@ -793,17 +793,18 @@ public class ActivityChooserModel extend
      * @return True if the record was added.
      */
     private boolean removeHistoricalRecordsForPackage(final String pkg) {
         boolean removed = false;
 
         for (Iterator<HistoricalRecord> i = mHistoricalRecords.iterator(); i.hasNext();) {
             final HistoricalRecord record = i.next();
             if (record.activity.getPackageName().equals(pkg)) {
-                removed = mHistoricalRecords.remove(record);
+                i.remove();
+                removed = true;
             }
         }
 
         if (removed) {
             mHistoricalRecordsChanged = true;
             pruneExcessiveHistoricalRecordsIfNeeded();
             persistHistoricalDataIfNeeded();
             sortActivitiesIfNeeded();