OSDN Git Service

Fix a concurrent issue in reload().
authorOwen Lin <owenlin@google.com>
Tue, 17 Apr 2012 04:12:03 +0000 (12:12 +0800)
committerOwen Lin <owenlin@google.com>
Tue, 17 Apr 2012 04:12:03 +0000 (12:12 +0800)
We need to hold the DataManager.LOCK when calling reload.

Change-Id: If908c233bcd835effffc7750a7ef07f56a63136c
fix: 6315479

src/com/android/gallery3d/data/LocalAlbumSet.java
src/com/android/gallery3d/data/MtpDeviceSet.java

index 56c84f3..47e3bd4 100644 (file)
@@ -207,7 +207,6 @@ public class LocalAlbumSet extends MediaSet
             for (BucketEntry entry : entries) {
                 MediaSet album = getLocalAlbum(dataManager,
                         mType, mPath, entry.bucketId, entry.bucketName);
-                album.reload();
                 albums.add(album);
             }
             return albums;
@@ -270,6 +269,9 @@ public class LocalAlbumSet extends MediaSet
         if (mLoadBuffer != null) {
             mAlbums = mLoadBuffer;
             mLoadBuffer = null;
+            for (MediaSet album : mAlbums) {
+                album.reload();
+            }
             mDataVersion = nextVersionNumber();
         }
         return mDataVersion;
index dd79bc1..46cc0fc 100644 (file)
@@ -76,10 +76,6 @@ public class MtpDeviceSet extends MediaSet
                 }
             }
             Collections.sort(result, MediaSetUtils.NAME_COMPARATOR);
-
-            for (int i = 0, n = result.size(); i < n; ++i) {
-                result.get(i).reload();
-            }
             return result;
         }
     }
@@ -122,6 +118,9 @@ public class MtpDeviceSet extends MediaSet
         if (mLoadBuffer != null) {
             mDeviceSet = mLoadBuffer;
             mLoadBuffer = null;
+            for (MediaSet device : mDeviceSet) {
+                device.reload();
+            }
             mDataVersion = nextVersionNumber();
         }
         return mDataVersion;