From 3bd60c7b1125ee42cd7e8746aeaebdb43e8211d8 Mon Sep 17 00:00:00 2001 From: Raph Levien Date: Wed, 6 May 2015 14:26:35 -0700 Subject: [PATCH] Clear all StaticLayout.Builder fields on pool recycle When returning a StaticLayout.Builder object to the pool, it is important to clear everything out. If not, then the object may have stale state from a previous layout operation. This was causing CTS test failures and probably other mischief. Bug: 20636917 Change-Id: I76fb20076ee954fcb476131a8fbe8833d72fbc0d --- core/java/android/text/StaticLayout.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/core/java/android/text/StaticLayout.java b/core/java/android/text/StaticLayout.java index 451abea951d67..59c7c6d34eb83 100644 --- a/core/java/android/text/StaticLayout.java +++ b/core/java/android/text/StaticLayout.java @@ -91,6 +91,7 @@ public class StaticLayout extends Layout { b.mEllipsizedWidth = width; b.mEllipsize = null; b.mMaxLines = Integer.MAX_VALUE; + b.mBreakStrategy = Layout.BREAK_STRATEGY_SIMPLE; b.mMeasuredText = MeasuredText.obtain(); return b; @@ -100,6 +101,8 @@ public class StaticLayout extends Layout { b.mPaint = null; b.mText = null; MeasuredText.recycle(b.mMeasuredText); + b.mMeasuredText = null; + nFinishBuilder(b.mNativePtr); sPool.release(b); }