From 01cb544dfd3e8a00c1da10cff3beccbb856a2396 Mon Sep 17 00:00:00 2001 From: Kelvin Date: Mon, 7 Jul 2025 16:42:37 +0200 Subject: [PATCH] Dont lock clients when disabling --- .../com/futo/platformplayer/states/StatePlatform.kt | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/com/futo/platformplayer/states/StatePlatform.kt b/app/src/main/java/com/futo/platformplayer/states/StatePlatform.kt index 1f1e5625..bd952cf2 100644 --- a/app/src/main/java/com/futo/platformplayer/states/StatePlatform.kt +++ b/app/src/main/java/com/futo/platformplayer/states/StatePlatform.kt @@ -395,8 +395,9 @@ class StatePlatform { } suspend fun selectClients(afterLoad: (() -> Unit)?, vararg ids: String) { withContext(Dispatchers.IO) { + var removed: MutableList; synchronized(_clientsLock) { - val removed = _enabledClients.toMutableList(); + removed = _enabledClients.toMutableList(); _enabledClients.clear(); for (id in ids) { val client = getClient(id); @@ -412,11 +413,11 @@ class StatePlatform { } _enabledClientsPersistent.set(*ids); _enabledClientsPersistent.save(); + } - for (oldClient in removed) { - oldClient.disable(); - onSourceDisabled.emit(oldClient); - } + for (oldClient in removed) { + oldClient.disable(); + onSourceDisabled.emit(oldClient); } afterLoad?.invoke(); };