diff options
author | Jason Sams <rjsams@android.com> | 2009-09-27 17:51:44 -0700 |
---|---|---|
committer | Jason Sams <rjsams@android.com> | 2009-09-27 17:51:44 -0700 |
commit | 0a8dc2cd98ddb89ebde88096de8053ad57c45e09 (patch) | |
tree | 91eeb478c33ae5f22fc09dd3a9416c9b334bc714 /src/com/android/launcher2/AllAppsView.java | |
parent | 05de32aec2918041d575829ecc928d2d16c45dc3 (diff) | |
download | android_packages_apps_Trebuchet-0a8dc2cd98ddb89ebde88096de8053ad57c45e09.tar.gz android_packages_apps_Trebuchet-0a8dc2cd98ddb89ebde88096de8053ad57c45e09.tar.bz2 android_packages_apps_Trebuchet-0a8dc2cd98ddb89ebde88096de8053ad57c45e09.zip |
Fix use of zero sized allocation. Add check to make sure the read object has not become null while waiting for the message to arrive.
Diffstat (limited to 'src/com/android/launcher2/AllAppsView.java')
-rw-r--r-- | src/com/android/launcher2/AllAppsView.java | 44 |
1 files changed, 25 insertions, 19 deletions
diff --git a/src/com/android/launcher2/AllAppsView.java b/src/com/android/launcher2/AllAppsView.java index bef6cc405..ae4467749 100644 --- a/src/com/android/launcher2/AllAppsView.java +++ b/src/com/android/launcher2/AllAppsView.java @@ -338,7 +338,10 @@ public class AllAppsView extends RSSurfaceView Handler mReadZoom = new Handler() { public void handleMessage(Message msg) { - mRollo.mReadback.read(); + if(mRollo != null && mRollo.mReadback != null) { + // FIXME: These checks may indicate other problems. + mRollo.mReadback.read(); + } } }; @@ -490,7 +493,9 @@ public class AllAppsView extends RSSurfaceView } void read() { - mAlloc.read(this); + if(mAlloc != null) { + mAlloc.read(this); + } } } @@ -571,16 +576,14 @@ public class AllAppsView extends RSSurfaceView mRS.contextBindProgramVertex(mPV); mTouchXBorders = new int[Defines.COLUMNS_PER_PAGE+1]; - mAllocTouchXBorders = Allocation.createSized(mRS, Element.USER_I32, + mAllocTouchXBorders = Allocation.createSized(mRS, Element.USER_I32(mRS), mTouchXBorders.length); mAllocTouchXBorders.data(mTouchXBorders); mTouchYBorders = new int[Defines.ROWS_PER_PAGE+1]; - mAllocTouchYBorders = Allocation.createSized(mRS, Element.USER_I32, + mAllocTouchYBorders = Allocation.createSized(mRS, Element.USER_I32(mRS), mTouchYBorders.length); mAllocTouchYBorders.data(mTouchYBorders); - - Log.e("rs", "Done loading named"); } private void initData() { @@ -596,7 +599,7 @@ public class AllAppsView extends RSSurfaceView mParams.bubbleBitmapHeight = bubble.getBitmapHeight(); mScrollHandle = Allocation.createFromBitmapResource(mRS, mRes, - R.drawable.all_apps_button_pow2, Element.RGBA_8888, false); + R.drawable.all_apps_button_pow2, Element.RGBA_8888(mRS), false); mScrollHandle.uploadToTexture(0); mParams.scrollHandleId = mScrollHandle.getID(); Log.d(TAG, "mParams.scrollHandleId=" + mParams.scrollHandleId); @@ -644,15 +647,20 @@ public class AllAppsView extends RSSurfaceView private void setApps(ArrayList<ApplicationInfo> list) { final int count = list != null ? list.size() : 0; + int allocCount = count; + if(allocCount < 1) { + allocCount = 1; + } + mIcons = new Allocation[count]; - mIconIds = new int[count]; - mAllocIconID = Allocation.createSized(mRS, Element.USER_I32, count); + mIconIds = new int[allocCount]; + mAllocIconID = Allocation.createSized(mRS, Element.USER_I32(mRS), allocCount); mLabels = new Allocation[count]; - mLabelIds = new int[count]; - mAllocLabelID = Allocation.createSized(mRS, Element.USER_I32, count); + mLabelIds = new int[allocCount]; + mAllocLabelID = Allocation.createSized(mRS, Element.USER_I32(mRS), allocCount); - Element ie8888 = Element.RGBA_8888; + Element ie8888 = Element.RGBA_8888(mRS); Utilities.BubbleText bubble = new Utilities.BubbleText(getContext()); @@ -660,9 +668,9 @@ public class AllAppsView extends RSSurfaceView final ApplicationInfo item = list.get(i); mIcons[i] = Allocation.createFromBitmap(mRS, item.iconBitmap, - Element.RGBA_8888, false); + Element.RGBA_8888(mRS), false); mLabels[i] = Allocation.createFromBitmap(mRS, item.titleBitmap, - Element.RGBA_8888, false); + Element.RGBA_8888(mRS), false); mIcons[i].uploadToTexture(0); mLabels[i].uploadToTexture(0); @@ -671,10 +679,8 @@ public class AllAppsView extends RSSurfaceView mLabelIds[i] = mLabels[i].getID(); } - if(count > 0) { - mAllocIconID.data(mIconIds); - mAllocLabelID.data(mLabelIds); - } + mAllocIconID.data(mIconIds); + mAllocLabelID.data(mLabelIds); mState.iconCount = count; @@ -769,7 +775,7 @@ public class AllAppsView extends RSSurfaceView mAllAppsList.get(index).iconBitmap); mSelectedIcon = Allocation.createFromBitmap(mRS, selectionBitmap, - Element.RGBA_8888, false); + Element.RGBA_8888(mRS), false); mSelectedIcon.uploadToTexture(0); mState.selectedIconTexture = mSelectedIcon.getID(); } |