fix crash if cancel migration too soon
This commit is contained in:
parent
55906548ee
commit
dd0c3a516e
2 changed files with 4 additions and 3 deletions
|
|
@ -22,7 +22,7 @@ class MigratingManga(
|
|||
val migrationScope = CoroutineScope(parentContext + SupervisorJob() + Dispatchers.Default)
|
||||
|
||||
// KMK -->
|
||||
lateinit var searchingJob: Deferred<Manga?>
|
||||
var searchingJob: Deferred<Manga?>? = null
|
||||
// KMK <--
|
||||
|
||||
val searchResult = MutableStateFlow<SearchResult>(SearchResult.Searching)
|
||||
|
|
|
|||
|
|
@ -296,7 +296,7 @@ class MigrationListScreenModel(
|
|||
}
|
||||
}
|
||||
// KMK -->
|
||||
manga.searchingJob.await()
|
||||
manga.searchingJob?.await()
|
||||
// KMK <--
|
||||
} catch (e: CancellationException) {
|
||||
// Ignore canceled migrations
|
||||
|
|
@ -571,7 +571,8 @@ class MigrationListScreenModel(
|
|||
screenModelScope.launchIO {
|
||||
val item = migratingItems.value.orEmpty().find { it.manga.id == mangaId }
|
||||
?: return@launchIO
|
||||
item.searchingJob.cancel()
|
||||
item.searchingJob?.cancel()
|
||||
item.searchingJob = null
|
||||
item.searchResult.value = SearchResult.NotFound
|
||||
sourceFinished()
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue