Skip to content

Commit 15e1b05

Browse files
david-allisonmikehardy
authored andcommitted
fix: fallback if 'multiselect-values' not found
Instead, fallback to no selections I could not reproduce this crash, it did not seem like a cache clearing bug, as I didn't see logs for other IdsFile issues I suspect this is somehow due to `CardBrowser` being the initially launched activity Issue 19572
1 parent da59684 commit 15e1b05

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

AnkiDroid/src/main/java/com/ichi2/anki/browser/CardBrowserViewModel.kt

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,21 @@ class CardBrowserViewModel(
455455
savedStateHandle.get<Bundle>(STATE_MULTISELECT_VALUES)?.let { bundle ->
456456
BundleCompat.getParcelable(bundle, STATE_MULTISELECT_VALUES, IdsFile::class.java)
457457
}
458-
val ids = idsFile?.getIds()?.map { CardOrNoteId(it) } ?: emptyList()
458+
val ids =
459+
try {
460+
idsFile?.getIds()?.map { CardOrNoteId(it) }
461+
} catch (e: Exception) {
462+
// #19572: I suspect we have a startup bug here, so continue reporting the exception
463+
Timber.w(e, "failed to read STATE_MULTISELECT_VALUES")
464+
CrashReportService.sendExceptionReport(
465+
e = e,
466+
origin = "19572: STATE_MULTISELECT_VALUES",
467+
additionalInfo = null,
468+
onlyIfSilent = true,
469+
)
470+
// fallback to no selections, but still in multiselect mode
471+
null
472+
} ?: emptyList()
459473

460474
launchSearchForCards(cardOrNoteIdsToSelect = ids)
461475
}

0 commit comments

Comments
 (0)