From d0e462e3cd6ec64c1d7267f9dbf36c5e7503a693 Mon Sep 17 00:00:00 2001 From: Sergey Prigogin Date: Tue, 25 Apr 2017 16:29:44 -0700 Subject: Fix a NPE with outlineProvider="none" Do not attempt to draw outline when outline provider is null. Test: manually follow the steps in https://b.corp.google.com/issues/37139123#comment1 Bug: https://issuetracker.google.com/37139123 Change-Id: I6e09c187d5a8e1364e2ecbe12bbb5a17ad057965 Signed-off-by: Sergey Prigogin --- .../bridge/src/android/view/ViewGroup_Delegate.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/tools/layoutlib/bridge/src/android/view/ViewGroup_Delegate.java b/tools/layoutlib/bridge/src/android/view/ViewGroup_Delegate.java index 23caaf85eb8e..4b760a7d4638 100644 --- a/tools/layoutlib/bridge/src/android/view/ViewGroup_Delegate.java +++ b/tools/layoutlib/bridge/src/android/view/ViewGroup_Delegate.java @@ -50,12 +50,14 @@ public class ViewGroup_Delegate { // the outline obtained is correct. child.setBackgroundBounds(); ViewOutlineProvider outlineProvider = child.getOutlineProvider(); - Outline outline = child.mAttachInfo.mTmpOutline; - outlineProvider.getOutline(child, outline); - if (outline.mPath != null || (outline.mRect != null && !outline.mRect.isEmpty())) { - int restoreTo = transformCanvas(thisVG, canvas, child); - drawShadow(thisVG, canvas, child, outline); - canvas.restoreToCount(restoreTo); + if (outlineProvider != null) { + Outline outline = child.mAttachInfo.mTmpOutline; + outlineProvider.getOutline(child, outline); + if (outline.mPath != null || (outline.mRect != null && !outline.mRect.isEmpty())) { + int restoreTo = transformCanvas(thisVG, canvas, child); + drawShadow(thisVG, canvas, child, outline); + canvas.restoreToCount(restoreTo); + } } } return thisVG.drawChild_Original(canvas, child, drawingTime); -- cgit v1.2.3-59-g8ed1b