Skip to content

Commit 1558cf1

Browse files
author
Romain Guy
committed
Fix crash in ShapeDrawable
Change-Id: Ibc277db46912a73dc3f971f8487baa5eafa8bc84
1 parent 7c02632 commit 1558cf1

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)