From e4d102fe83cdacf07269ce2ffd5379cd0e8df811 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Mon, 21 Nov 2022 09:08:44 +0200 Subject: [PATCH] For #8054 - Focus should not crash when search engines are restored. (#8059) (cherry picked from commit 63ba2416e5832bcc7999b91ee3f0e3539f73a2f2) Co-authored-by: iorgamgabriel --- .../mozilla/focus/search/RadioSearchEngineListPreference.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/org/mozilla/focus/search/RadioSearchEngineListPreference.kt b/app/src/main/java/org/mozilla/focus/search/RadioSearchEngineListPreference.kt index 74d855be1c3..eda57017ff4 100644 --- a/app/src/main/java/org/mozilla/focus/search/RadioSearchEngineListPreference.kt +++ b/app/src/main/java/org/mozilla/focus/search/RadioSearchEngineListPreference.kt @@ -39,14 +39,14 @@ class RadioSearchEngineListPreference : SearchEngineListPreference, RadioGroup.O } override fun onCheckedChanged(group: RadioGroup, checkedId: Int) { - val selectedEngine = group.getChildAt(checkedId) + val selectedEngine = group.getChildAt(checkedId) ?: return // check if the corresponding button was pressed or a11y focused. val hasProperState = selectedEngine.isPressed || selectedEngine.isAccessibilityFocused /* onCheckedChanged is called intermittently before the search engine table is full, so we must check these conditions to prevent crashes and inconsistent states. */ - if (group.childCount != searchEngines.count() || selectedEngine == null || !hasProperState) { + if (group.childCount != searchEngines.count() || !hasProperState) { return }