diff options
author | Owen Lin <owenlin@google.com> | 2012-04-17 15:38:36 +0800 |
---|---|---|
committer | Owen Lin <owenlin@google.com> | 2012-04-18 17:35:40 +0800 |
commit | 48ba94ae713dbf57898cfa84ae69517da50cf7a0 (patch) | |
tree | 238542a589e8a16f904bea153578f51c1bfbd241 /src/com/android/gallery3d/app/ManageCachePage.java | |
parent | 29763f7a278c5d894f3590db1809c56e5a2b9a0a (diff) | |
download | android_packages_apps_Gallery2-48ba94ae713dbf57898cfa84ae69517da50cf7a0.tar.gz android_packages_apps_Gallery2-48ba94ae713dbf57898cfa84ae69517da50cf7a0.tar.bz2 android_packages_apps_Gallery2-48ba94ae713dbf57898cfa84ae69517da50cf7a0.zip |
Fix NPE in SlotView.
This NPE is actually a concurrent issue. We shall lock renderring when we clean up
the slots' data. But it didn't, so it may access to null data.
Change-Id: I2a8abfbb77f83bd9a240477fa53216ce69b7774d
fix: 6302487
fix: 6308873
Diffstat (limited to 'src/com/android/gallery3d/app/ManageCachePage.java')
-rw-r--r-- | src/com/android/gallery3d/app/ManageCachePage.java | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/src/com/android/gallery3d/app/ManageCachePage.java b/src/com/android/gallery3d/app/ManageCachePage.java index 5793b7065..94ebf9206 100644 --- a/src/com/android/gallery3d/app/ManageCachePage.java +++ b/src/com/android/gallery3d/app/ManageCachePage.java @@ -17,7 +17,6 @@ package com.android.gallery3d.app; import android.app.Activity; -import android.content.Context; import android.content.res.Configuration; import android.os.Bundle; import android.os.Handler; @@ -38,6 +37,7 @@ import com.android.gallery3d.data.MediaSet; import com.android.gallery3d.data.Path; import com.android.gallery3d.ui.CacheStorageUsageInfo; import com.android.gallery3d.ui.GLCanvas; +import com.android.gallery3d.ui.GLRoot; import com.android.gallery3d.ui.GLView; import com.android.gallery3d.ui.ManageCacheDrawer; import com.android.gallery3d.ui.MenuExecutor; @@ -286,7 +286,7 @@ public class ManageCachePage extends ActivityState implements mSelectionManager.setSelectionListener(this); Config.ManageCachePage config = Config.ManageCachePage.get(activity); - mSlotView = new SlotView((Context) mActivity, config.slotViewSpec); + mSlotView = new SlotView(mActivity, config.slotViewSpec); mSelectionDrawer = new ManageCacheDrawer(mActivity, mSelectionManager, mSlotView, config.labelSpec, config.cachePinSize, config.cachePinMargin); mSlotView.setSlotRenderer(mSelectionDrawer); @@ -324,17 +324,22 @@ public class ManageCachePage extends ActivityState implements @Override public void onClick(View view) { Utils.assertTrue(view.getId() == R.id.done); + GLRoot root = mActivity.getGLRoot(); + root.lockRenderThread(); + try { + ArrayList<Path> ids = mSelectionManager.getSelected(false); + if (ids.size() == 0) { + onBackPressed(); + return; + } + showToast(); - ArrayList<Path> ids = mSelectionManager.getSelected(false); - if (ids.size() == 0) { - onBackPressed(); - return; + MenuExecutor menuExecutor = new MenuExecutor(mActivity, mSelectionManager); + menuExecutor.startAction(R.id.action_toggle_full_caching, + R.string.process_caching_requests, this); + } finally { + root.unlockRenderThread(); } - showToast(); - - MenuExecutor menuExecutor = new MenuExecutor(mActivity, mSelectionManager); - menuExecutor.startAction(R.id.action_toggle_full_caching, - R.string.process_caching_requests, this); } private void showToast() { |