From a5ec16679419e3de23c414705beecc416ee3ec1b Mon Sep 17 00:00:00 2001 From: Green Sky Date: Sun, 26 May 2024 11:32:06 +0200 Subject: [PATCH] fix lock recursion (on eg windows) --- src/chat_gui4.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/chat_gui4.cpp b/src/chat_gui4.cpp index 4b88d264..7c0d6e26 100644 --- a/src/chat_gui4.cpp +++ b/src/chat_gui4.cpp @@ -154,10 +154,14 @@ void ChatGui4::setClipboardData(std::vector mime_types, std::shared std::vector tmp_mimetype_list; - std::lock_guard lg{_set_clipboard_data_mutex}; - for (const auto& mime_type : mime_types) { - tmp_mimetype_list.push_back(mime_type.data()); - _set_clipboard_data[mime_type] = data; + { + std::lock_guard lg{_set_clipboard_data_mutex}; + for (const auto& mime_type : mime_types) { + tmp_mimetype_list.push_back(mime_type.data()); + _set_clipboard_data[mime_type] = data; + } + + // release lock, since on some platforms the callback is called immediatly } SDL_SetClipboardData(clipboard_callback, nullptr, this, tmp_mimetype_list.data(), tmp_mimetype_list.size());