Skip to content

Commit f9c283e

Browse files
committed
review: guard refreshMaterialAboutList with isAdded (avoid null adapter)
Per Greptile: if the fragment is detached while the battery-settings screen is open, the activity-result callback's refreshMaterialAboutList() could dereference a null adapter. Guard with isAdded, matching the checkUpdate() pattern.
1 parent 7a75da5 commit f9c283e

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

app/src/main/java/io/nekohasekai/sagernet/ui/AboutFragment.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@ class AboutFragment : ToolbarFragment(R.layout.layout_about) {
5252
// The battery-optimization request/settings screen returns RESULT_CANCELED even
5353
// when the user actually granted the exemption, so don't gate on the result code
5454
// — just rebuild the list so the item's on/off subtext reflects the new state.
55-
refreshMaterialAboutList()
55+
// Guard with isAdded: the fragment may be detached while the settings screen was
56+
// open, and refreshMaterialAboutList() would otherwise touch a null adapter.
57+
if (isAdded) refreshMaterialAboutList()
5658
}
5759

5860
override fun getMaterialAboutList(activityContext: Context): MaterialAboutList {

0 commit comments

Comments
 (0)