Skip to content

Commit be6024d

Browse files
Romain GuyAndroid (Google) Code Review
authored andcommitted
Merge "Fix crash in ShapeDrawable" into jb-mr1-dev
2 parents 1ac44eb + 1558cf1 commit be6024d

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

graphics/java/android/graphics/drawable/ShapeDrawable.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -373,8 +373,16 @@ public ConstantState getConstantState() {
373373
@Override
374374
public Drawable mutate() {
375375
if (!mMutated && super.mutate() == this) {
376-
mShapeState.mPaint = new Paint(mShapeState.mPaint);
377-
mShapeState.mPadding = new Rect(mShapeState.mPadding);
376+
if (mShapeState.mPaint != null) {
377+
mShapeState.mPaint = new Paint(mShapeState.mPaint);
378+
} else {
379+
mShapeState.mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
380+
}
381+
if (mShapeState.mPadding != null) {
382+
mShapeState.mPadding = new Rect(mShapeState.mPadding);
383+
} else {
384+
mShapeState.mPadding = new Rect();
385+
}
378386
try {
379387
mShapeState.mShape = mShapeState.mShape.clone();
380388
} catch (CloneNotSupportedException e) {

0 commit comments

Comments
 (0)