Răsfoiți Sursa

Fix broken use of MsgWaitForMultipleObjects.

- Timeout < 0 was not handled properly
- Return value for success is WAIT_OBJECT_0 + nCount, not positive value

(cherry picked from commit 69f2bd151ece3c00d1850d90da137053b1936b16)
(cherry picked from commit 4ae87e215ee068257dd7581f9837a71f4799abe8)
Hans-Kristian Arntzen 1 an în urmă
părinte
comite
c4fc20a033
1 a modificat fișierele cu 4 adăugiri și 1 ștergeri
  1. 4 1
      src/video/windows/SDL_windowsevents.c

+ 4 - 1
src/video/windows/SDL_windowsevents.c

@@ -1803,7 +1803,10 @@ void SDL_SetWindowsMessageHook(SDL_WindowsMessageHook callback, void *userdata)
 int WIN_WaitEventTimeout(_THIS, int timeout)
 {
     if (g_WindowsEnableMessageLoop) {
-        if (MsgWaitForMultipleObjects(0, NULL, FALSE, (DWORD)timeout, QS_ALLINPUT)) {
+        DWORD dwMilliseconds, ret;
+        dwMilliseconds = timeout < 0 ? INFINITE : (DWORD)timeout;
+        ret = MsgWaitForMultipleObjects(0, NULL, FALSE, dwMilliseconds, QS_ALLINPUT);
+        if (ret == WAIT_OBJECT_0) {
             return 1;
         } else {
             return 0;