File tree Expand file tree Collapse file tree
graphics/java/android/graphics/drawable Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -348,15 +348,19 @@ public class VectorDrawable extends Drawable {
348348 private final Rect mTmpBounds = new Rect ();
349349
350350 public VectorDrawable () {
351- this (new VectorDrawableState ( null ) , null );
351+ this (null , null );
352352 }
353353
354354 /**
355355 * The one constructor to rule them all. This is called by all public
356356 * constructors to set the state and initialize local properties.
357357 */
358- private VectorDrawable (@ NonNull VectorDrawableState state , @ Nullable Resources res ) {
359- mVectorState = state ;
358+ private VectorDrawable (@ Nullable VectorDrawableState state , @ Nullable Resources res ) {
359+ // As the mutable, not-thread-safe native instance is stored in VectorDrawableState, we
360+ // need to always do a defensive copy even if mutate() isn't called. Otherwise
361+ // draw() being called on 2 different VectorDrawable instances could still hit the same
362+ // underlying native object.
363+ mVectorState = new VectorDrawableState (state );
360364 updateLocalState (res );
361365 }
362366
You can’t perform that action at this time.
0 commit comments