mirror of
https://github.com/skyline-emu/skyline.git
synced 2024-06-01 11:58:46 +02:00
Prevent a delayed coroutine from crashing
Checking state when the function is called only works if the coroutine is fired immediately. If it is delayed by another process, it will crash with a ClassCastException
This commit is contained in:
parent
d3d36c6fa0
commit
49f666cd8d
|
@ -78,8 +78,8 @@ class MainViewModel @Inject constructor(@ApplicationContext context : Context, p
|
|||
* This checks if the roms have changed since the last time they were loaded and if so it reloads them
|
||||
*/
|
||||
fun checkRomHash(searchLocation : Uri, systemLanguage : Int) {
|
||||
if(state !is MainState.Loaded) return
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
if (state !is MainState.Loaded) return@launch
|
||||
val currentHash = (state as MainState.Loaded).items.hashCode()
|
||||
val romElements = romProvider.loadRoms(searchLocation, systemLanguage)
|
||||
val newHash = romElements.hashCode()
|
||||
|
|
Loading…
Reference in New Issue
Block a user