From 1056547c705ebd9bca6dcb4e39755ff2601286e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sun, 18 May 2025 22:13:10 +0200 Subject: [PATCH] Windows: Don't freeze the UI thread for a sec while launching a URL --- Windows/main.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Windows/main.cpp b/Windows/main.cpp index b46c3e3c01..4d00b25236 100644 --- a/Windows/main.cpp +++ b/Windows/main.cpp @@ -133,7 +133,12 @@ static double g_lastKeepAwake = 0.0; static constexpr double ACTIVITY_IDLE_TIMEOUT = 2.0 * 3600.0; void System_LaunchUrl(LaunchUrlType urlType, const char *url) { - ShellExecute(NULL, L"open", ConvertUTF8ToWString(url).c_str(), NULL, NULL, SW_SHOWNORMAL); + std::string u(url); + std::thread t = std::thread([u]() { + ShellExecute(NULL, L"open", ConvertUTF8ToWString(u).c_str(), NULL, NULL, SW_SHOWNORMAL); + }); + // Detach is bad (given exit behavior), but in this case all the thread does is a ShellExecute to avoid freezing the caller while it runs, so it's safe. + t.detach(); } void System_Vibrate(int length_ms) {