Skip to content
This repository has been archived by the owner on Feb 20, 2023. It is now read-only.

Commit

Permalink
For #6832: fix unattached context crash in HomeFragment
Browse files Browse the repository at this point in the history
  • Loading branch information
severinrudie authored and ekager committed Jan 8, 2020
1 parent b115a00 commit 65f5ff6
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion app/src/main/java/org/mozilla/fenix/home/HomeFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,12 @@ class HomeFragment : Fragment() {
setupHomeMenu()

viewLifecycleOwner.lifecycleScope.launch(IO) {
// This should be unnecessary, but we've seen crashes around it. See #6832
val context = context ?: return@launch

val iconSize = resources.getDimensionPixelSize(R.dimen.preference_icon_drawable_size)

val searchEngine = requireComponents.search.provider.getDefaultEngine(requireContext())
val searchEngine = requireComponents.search.provider.getDefaultEngine(context)
val searchIcon = BitmapDrawable(resources, searchEngine.icon)
searchIcon.setBounds(0, 0, iconSize, iconSize)

Expand Down

0 comments on commit 65f5ff6

Please sign in to comment.