From a354c4f1565cb69ab0858b586c4f2071a46b1105 Mon Sep 17 00:00:00 2001 From: Yura Date: Tue, 24 Jan 2017 19:41:41 +0000 Subject: [PATCH] Fix for endless loop in RelativeLayout. getRelatedView(int[] rules, int relation) is stuck in the loop, when a view is GONE, and references itself. There is already a check in: getSortedViews(View[] sorted, int... rules) { to make sure there are no loops of ViewA -> ViewB -> ViewA BUT, there was a change made in findRoots(int[] rulesFilter) to "Remove exception throw when a view has a self dependency inside a RelativeLayout." so this means we must allow this case. Other change git commit sha: da3003e1d71d66a1c936489025f8db314a2a4588 Bug: http://b/android.com/231353 Change-Id: Icc26b86ebbb19e482c3afe6a39db996ec493586d --- core/java/android/widget/RelativeLayout.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/java/android/widget/RelativeLayout.java b/core/java/android/widget/RelativeLayout.java index b424101d0470a..67bfe5e606c55 100644 --- a/core/java/android/widget/RelativeLayout.java +++ b/core/java/android/widget/RelativeLayout.java @@ -1013,7 +1013,8 @@ public class RelativeLayout extends ViewGroup { while (v.getVisibility() == View.GONE) { rules = ((LayoutParams) v.getLayoutParams()).getRules(v.getLayoutDirection()); node = mGraph.mKeyNodes.get((rules[relation])); - if (node == null) return null; + // ignore self dependency. for more info look in git commit: da3003 + if (node == null || v == node.view) return null; v = node.view; }