From 2427192e58b2ff31c3238b6c04440a15f4e7bf20 Mon Sep 17 00:00:00 2001 From: Gilles Debunne Date: Fri, 25 May 2012 14:04:01 +0200 Subject: Fix for IOOB in SearchView Bug 6476578 The latest bug report show a query.length() of 33 while mQueryTextView.length() is 0 on line 514. I can see 2 reasons which can explain this discrepancy: - the mQueryTextView has a filter, which alters the text. - some asynchronous event (IME?) changes the text in the mean time. I would favor the second one, which seems to break a lot of single thread assumptions in the code and generates other IOOB exceptions. Note that depending on what they are used for, it may be more consistent to use mQueryTextView.getText() instead of query in the following assignment. Change-Id: Ie8a5486b11a80543f8f90980454933c5a74c073e --- core/java/android/widget/SearchView.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'core/java/android') diff --git a/core/java/android/widget/SearchView.java b/core/java/android/widget/SearchView.java index 521597b..8f3a311 100644 --- a/core/java/android/widget/SearchView.java +++ b/core/java/android/widget/SearchView.java @@ -511,7 +511,7 @@ public class SearchView extends LinearLayout implements CollapsibleActionView { public void setQuery(CharSequence query, boolean submit) { mQueryTextView.setText(query); if (query != null) { - mQueryTextView.setSelection(query.length()); + mQueryTextView.setSelection(mQueryTextView.length()); mUserQuery = query; } -- cgit v1.1