From f3883ee2d4d8773e6b77e36700edb4ca7cb0988e Mon Sep 17 00:00:00 2001 From: Amr Bashir Date: Mon, 27 Mar 2023 21:08:43 +0200 Subject: [PATCH] fix(windows): run the about dialog in its own thread, closes #57 (#60) --- .changes/windows-about-menu-item.md | 5 +++++ src/platform_impl/windows/mod.rs | 9 ++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 .changes/windows-about-menu-item.md diff --git a/.changes/windows-about-menu-item.md b/.changes/windows-about-menu-item.md new file mode 100644 index 0000000..d2c8d29 --- /dev/null +++ b/.changes/windows-about-menu-item.md @@ -0,0 +1,5 @@ +--- +"muda": "patch" +--- + +On Windows, fix panic when click a menu item while the `PredefinedMenuItem::about` dialog is open. diff --git a/src/platform_impl/windows/mod.rs b/src/platform_impl/windows/mod.rs index c37ea2a..3878a5c 100644 --- a/src/platform_impl/windows/mod.rs +++ b/src/platform_impl/windows/mod.rs @@ -1154,7 +1154,14 @@ unsafe extern "system" fn menu_subclass_proc( "About {}", metadata.name.as_deref().unwrap_or_default() )); - MessageBoxW(hwnd, message.as_ptr(), title.as_ptr(), MB_ICONINFORMATION); + std::thread::spawn(move || { + MessageBoxW( + hwnd, + message.as_ptr(), + title.as_ptr(), + MB_ICONINFORMATION, + ); + }); } _ => {}