Skip to content

Commit dd0c3a5

Browse files
committed
fix crash if cancel migration too soon
1 parent 5590654 commit dd0c3a5

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/advanced/process/MigratingManga.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class MigratingManga(
2222
val migrationScope = CoroutineScope(parentContext + SupervisorJob() + Dispatchers.Default)
2323

2424
// KMK -->
25-
lateinit var searchingJob: Deferred<Manga?>
25+
var searchingJob: Deferred<Manga?>? = null
2626
// KMK <--
2727

2828
val searchResult = MutableStateFlow<SearchResult>(SearchResult.Searching)

app/src/main/java/eu/kanade/tachiyomi/ui/browse/migration/advanced/process/MigrationListScreenModel.kt

+3-2
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ class MigrationListScreenModel(
296296
}
297297
}
298298
// KMK -->
299-
manga.searchingJob.await()
299+
manga.searchingJob?.await()
300300
// KMK <--
301301
} catch (e: CancellationException) {
302302
// Ignore canceled migrations
@@ -571,7 +571,8 @@ class MigrationListScreenModel(
571571
screenModelScope.launchIO {
572572
val item = migratingItems.value.orEmpty().find { it.manga.id == mangaId }
573573
?: return@launchIO
574-
item.searchingJob.cancel()
574+
item.searchingJob?.cancel()
575+
item.searchingJob = null
575576
item.searchResult.value = SearchResult.NotFound
576577
sourceFinished()
577578
}

0 commit comments

Comments
 (0)