Bug 1851259 - Delete browsing data only if fragment attached

We still encounter a crash during the process of deleting
browsing data. This is a speculative fix that does not start
the deletion process unless the fragment is attached.

(cherry picked from commit 1879088ea2b83c6e3107b3548a68382b211e9474)
fenix/119.0
DreVla 8 months ago committed by mergify[bot]
parent 2b1cebbcb4
commit 4c3ebcba94

@ -157,23 +157,25 @@ class DeleteBrowsingDataFragment : Fragment(R.layout.fragment_delete_browsing_da
}
private fun deleteSelected() {
startDeletion()
lifecycleScope.launch(IO) {
getCheckboxes().mapIndexed { i, v ->
if (v.isChecked) {
when (i) {
OPEN_TABS_INDEX -> controller.deleteTabs()
HISTORY_INDEX -> controller.deleteBrowsingHistory()
COOKIES_INDEX -> controller.deleteCookiesAndSiteData()
CACHED_INDEX -> controller.deleteCachedFiles()
PERMS_INDEX -> controller.deleteSitePermissions()
DOWNLOADS_INDEX -> controller.deleteDownloads()
runIfFragmentIsAttached {
startDeletion()
lifecycleScope.launch(IO) {
getCheckboxes().mapIndexed { i, v ->
if (v.isChecked) {
when (i) {
OPEN_TABS_INDEX -> controller.deleteTabs()
HISTORY_INDEX -> controller.deleteBrowsingHistory()
COOKIES_INDEX -> controller.deleteCookiesAndSiteData()
CACHED_INDEX -> controller.deleteCachedFiles()
PERMS_INDEX -> controller.deleteSitePermissions()
DOWNLOADS_INDEX -> controller.deleteDownloads()
}
}
}
}
withContext(Main) {
finishDeletion()
withContext(Main) {
finishDeletion()
}
}
}
}

Loading…
Cancel
Save