From 9fe7419467ee06e5d8c76b6f4a071eeac651f8cc Mon Sep 17 00:00:00 2001 From: mosayeb Date: Wed, 3 Jan 2024 11:15:00 -0800 Subject: [PATCH] fix a bug(ConcurrentModificationException) --- .../src/main/kotlin/com/v2ray/ang/viewmodel/MainViewModel.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/viewmodel/MainViewModel.kt b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/viewmodel/MainViewModel.kt index eeae055fc..8a1e05ce4 100644 --- a/V2rayNG/app/src/main/kotlin/com/v2ray/ang/viewmodel/MainViewModel.kt +++ b/V2rayNG/app/src/main/kotlin/com/v2ray/ang/viewmodel/MainViewModel.kt @@ -140,9 +140,11 @@ class MainViewModel(application: Application) : AndroidViewModel(application) { MmkvManager.clearAllTestDelayResults() updateListAction.value = -1 // update all + val serversCopy = serversCache.toList() // Create a copy of the list + getApplication().toast(R.string.connection_test_testing) viewModelScope.launch(Dispatchers.Default) { // without Dispatchers.Default viewModelScope will launch in main thread - for (item in serversCache) { + for (item in serversCopy) { val config = V2rayConfigUtil.getV2rayConfig(getApplication(), item.guid) if (config.status) { MessageUtil.sendMsg2TestService(getApplication(), AppConfig.MSG_MEASURE_CONFIG, Pair(item.guid, config.content))