Skip to content

Commit

Permalink
Merge pull request #2721 from mosayeb-a/fix-bug
Browse files Browse the repository at this point in the history
fix a bug(ConcurrentModificationException)
  • Loading branch information
2dust authored Jan 5, 2024
2 parents 41b2251 + 9fe7419 commit 5e4d924
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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<AngApplication>().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))
Expand Down

0 comments on commit 5e4d924

Please sign in to comment.