From 6aa5a44d9b65ee608df03df29dad640258548f10 Mon Sep 17 00:00:00 2001 From: Diego Perez Date: Tue, 21 Apr 2015 11:33:55 +0100 Subject: Fix isThemeAppCompat NPE when using an invalid theme When the theme does not longer exists on the Android Studio side, getDefaultTheme will return null causing isThemeAppCompat to crash. Change-Id: I5a5c17126dce72e9872522643219b9438666bc04 --- .../src/com/android/layoutlib/bridge/impl/RenderSessionImpl.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'tools/layoutlib') diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderSessionImpl.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderSessionImpl.java index 95576ef..d830450 100644 --- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderSessionImpl.java +++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderSessionImpl.java @@ -1199,15 +1199,15 @@ public class RenderSessionImpl extends RenderAction { // between Theme.AppCompat.Light and Theme.AppCompat is Theme.Material (for v21). boolean isThemeAppCompat = false; for (int i = 0; i < 50; i++) { + if (defaultTheme == null) { + break; + } // for loop ensures that we don't run into cyclic theme inheritance. if (defaultTheme.getName().startsWith("Theme.AppCompat")) { isThemeAppCompat = true; break; } defaultTheme = resources.getParent(defaultTheme); - if (defaultTheme == null) { - break; - } } mIsThemeAppCompat = isThemeAppCompat; } -- cgit v1.1