OSDN Git Service

Fix NPE in Gallery.
authorOwen Lin <owenlin@google.com>
Thu, 5 Apr 2012 04:02:01 +0000 (12:02 +0800)
committerOwen Lin <owenlin@google.com>
Thu, 5 Apr 2012 04:04:24 +0000 (12:04 +0800)
bug: 6249248

Change-Id: I41851c6524163195f6296a15893d962e706b3449

src/com/android/gallery3d/app/AlbumPage.java
src/com/android/gallery3d/app/AlbumSetPage.java

index e0b7384..3d8c86d 100644 (file)
@@ -45,6 +45,7 @@ import com.android.gallery3d.ui.AlbumView;
 import com.android.gallery3d.ui.DetailsHelper;
 import com.android.gallery3d.ui.DetailsHelper.CloseListener;
 import com.android.gallery3d.ui.GLCanvas;
+import com.android.gallery3d.ui.GLRoot;
 import com.android.gallery3d.ui.GLView;
 import com.android.gallery3d.ui.GridDrawer;
 import com.android.gallery3d.ui.HighlightDrawer;
@@ -561,13 +562,19 @@ public class AlbumPage extends ActivityState implements GalleryActionBar.Cluster
         ((Activity) mActivity).runOnUiThread(new Runnable() {
             @Override
             public void run() {
-                if (resultCode == MediaSet.SYNC_RESULT_SUCCESS) {
-                    mInitialSynced = true;
-                }
-                clearLoadingBit(BIT_LOADING_SYNC);
-                if (resultCode == MediaSet.SYNC_RESULT_ERROR && mIsActive) {
-                    Toast.makeText((Context) mActivity, R.string.sync_album_error,
-                            Toast.LENGTH_LONG).show();
+                GLRoot root = mActivity.getGLRoot();
+                root.lockRenderThread();
+                try {
+                    if (resultCode == MediaSet.SYNC_RESULT_SUCCESS) {
+                        mInitialSynced = true;
+                    }
+                    clearLoadingBit(BIT_LOADING_SYNC);
+                    if (resultCode == MediaSet.SYNC_RESULT_ERROR && mIsActive) {
+                        Toast.makeText((Context) mActivity, R.string.sync_album_error,
+                                Toast.LENGTH_LONG).show();
+                    }
+                } finally {
+                    root.unlockRenderThread();
                 }
             }
         });
index 7b87501..6b4bb00 100644 (file)
@@ -44,6 +44,7 @@ import com.android.gallery3d.ui.AlbumSetView;
 import com.android.gallery3d.ui.DetailsHelper;
 import com.android.gallery3d.ui.DetailsHelper.CloseListener;
 import com.android.gallery3d.ui.GLCanvas;
+import com.android.gallery3d.ui.GLRoot;
 import com.android.gallery3d.ui.GLView;
 import com.android.gallery3d.ui.GridDrawer;
 import com.android.gallery3d.ui.HighlightDrawer;
@@ -574,13 +575,19 @@ public class AlbumSetPage extends ActivityState implements
         ((Activity) mActivity).runOnUiThread(new Runnable() {
             @Override
             public void run() {
-                if (resultCode == MediaSet.SYNC_RESULT_SUCCESS) {
-                    mInitialSynced = true;
-                }
-                clearLoadingBit(BIT_LOADING_SYNC);
-                if (resultCode == MediaSet.SYNC_RESULT_ERROR && mIsActive) {
-                    Toast.makeText((Context) mActivity, R.string.sync_album_set_error,
-                            Toast.LENGTH_LONG).show();
+                GLRoot root = mActivity.getGLRoot();
+                root.lockRenderThread();
+                try {
+                    if (resultCode == MediaSet.SYNC_RESULT_SUCCESS) {
+                        mInitialSynced = true;
+                    }
+                    clearLoadingBit(BIT_LOADING_SYNC);
+                    if (resultCode == MediaSet.SYNC_RESULT_ERROR && mIsActive) {
+                        Toast.makeText((Context) mActivity, R.string.sync_album_set_error,
+                                Toast.LENGTH_LONG).show();
+                    }
+                } finally {
+                    root.unlockRenderThread();
                 }
             }
         });