From d00dd5a83d16ff6e32e67bf0c8fd3d0e4d105f9e Mon Sep 17 00:00:00 2001 From: NicknineTheEagle Date: Tue, 1 Oct 2024 00:45:11 +0300 Subject: [PATCH] [XAM] Send UI close notification on a separate thread --- src/xenia/kernel/xam/xam_ui.cc | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/xenia/kernel/xam/xam_ui.cc b/src/xenia/kernel/xam/xam_ui.cc index 7b7abb026..6fc6a8058 100644 --- a/src/xenia/kernel/xam/xam_ui.cc +++ b/src/xenia/kernel/xam/xam_ui.cc @@ -212,14 +212,18 @@ X_RESULT xeXamDispatchDialogAsync(T* dialog, // Important to pass captured vars by value here since we return from this // without waiting for the dialog to close so the original local vars will be // destroyed. - // FIXME: Probably not the best idea to call Sleep in UI thread. dialog->set_close_callback([dialog, close_callback]() { close_callback(dialog); --xam_dialogs_shown_; - xe::threading::Sleep(std::chrono::milliseconds(100)); - kernel_state()->BroadcastNotification(kXNotificationIDSystemUI, false); + auto run = []() -> void { + xe::threading::Sleep(std::chrono::milliseconds(100)); + kernel_state()->BroadcastNotification(kXNotificationIDSystemUI, false); + }; + + std::thread thread(run); + thread.detach(); }); return X_ERROR_SUCCESS; @@ -235,8 +239,13 @@ X_RESULT xeXamDispatchHeadlessAsync(std::function run_callback) { --xam_dialogs_shown_; - xe::threading::Sleep(std::chrono::milliseconds(100)); - kernel_state()->BroadcastNotification(kXNotificationIDSystemUI, false); + auto run = []() -> void { + xe::threading::Sleep(std::chrono::milliseconds(100)); + kernel_state()->BroadcastNotification(kXNotificationIDSystemUI, false); + }; + + std::thread thread(run); + thread.detach(); }); return X_ERROR_SUCCESS;