From 53bee4eb5664387c415b45022436bfccfd50497e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pedro=20J=2E=20Est=C3=A9banez?= Date: Thu, 15 May 2025 10:12:16 +0200 Subject: [PATCH] Windows: Restrict time API use to the desktop flavor --- platform/windows/os_windows.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index b54a821cd80..70c61e1d249 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -281,6 +281,7 @@ void OS_Windows::initialize() { QueryPerformanceFrequency((LARGE_INTEGER *)&ticks_per_second); QueryPerformanceCounter((LARGE_INTEGER *)&ticks_start); +#if WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP // set minimum resolution for periodic timers, otherwise Sleep(n) may wait at least as // long as the windows scheduler resolution (~16-30ms) even for calls like Sleep(1) TIMECAPS time_caps; @@ -292,6 +293,9 @@ void OS_Windows::initialize() { delay_resolution = 1000; timeBeginPeriod(1); } +#else + delay_resolution = 1000; +#endif process_map = memnew((HashMap)); @@ -374,7 +378,9 @@ void OS_Windows::finalize_core() { FileAccessWindows::finalize(); +#if WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP timeEndPeriod(1); +#endif memdelete(process_map); NetSocketWinSock::cleanup();