From ee555e0da9f80bce1856fe3712debf1aa4481d3d Mon Sep 17 00:00:00 2001 From: WerWolv Date: Tue, 31 Dec 2024 18:06:31 +0100 Subject: [PATCH] fix: Make sure WM_NCCALCSIZE never tries to sleep a negative amount of time #1842 --- main/gui/source/window/win_window.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/main/gui/source/window/win_window.cpp b/main/gui/source/window/win_window.cpp index 598b8c0b7..7a0b37470 100644 --- a/main/gui/source/window/win_window.cpp +++ b/main/gui/source/window/win_window.cpp @@ -206,13 +206,14 @@ namespace hex { if (delta >= 0) { sleepTicks = delta / period; } else { - sleepTicks = -1 + delta / period; } sleepMilliSeconds = delta - (period * sleepTicks); - const double sleepTime = (1000.0 * double(sleepMilliSeconds) / double(performanceFrequency.QuadPart)); - Sleep(DWORD(std::round(sleepTime))); + const double sleepTime = std::round(1000.0 * double(sleepMilliSeconds) / double(performanceFrequency.QuadPart)); + if (sleepTime >= 0.0) { + Sleep(DWORD(sleepTime)); + } timeEndPeriod(granularity); return WVR_REDRAW;