From 9b97e68da38f93d361278a2459930e3610a49bf6 Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Thu, 1 Jun 2023 16:18:51 +0200 Subject: [PATCH] uriplaylistbin: prevent deadlock when notifying property changes Part-of: --- utils/uriplaylistbin/src/uriplaylistbin/imp.rs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/utils/uriplaylistbin/src/uriplaylistbin/imp.rs b/utils/uriplaylistbin/src/uriplaylistbin/imp.rs index 1b26ebc7..c3de6202 100644 --- a/utils/uriplaylistbin/src/uriplaylistbin/imp.rs +++ b/utils/uriplaylistbin/src/uriplaylistbin/imp.rs @@ -1679,12 +1679,26 @@ impl UriPlaylistBin { } let element = self.obj(); + let mut notify_iteration = false; + let mut notify_index = false; + if current_iteration != state.current_iteration { state.current_iteration = current_iteration; - element.notify("current-iteration"); + notify_iteration = true; } if current_uri_index != state.current_uri_index { state.current_uri_index = current_uri_index; + notify_index = true; + } + + // drop mutex before notifying changes as the callback will likely try to fetch the updated values + // which would deadlock. + drop(state_guard); + + if notify_iteration { + element.notify("current-iteration"); + } + if notify_index { element.notify("current-uri-index"); } }