瀏覽代碼

tests: Flush events after an SDL_WaitEvent() call

SDL_WaitEvent() will pump OS events if no poll sentinel is pending, so flush events before inserting a user event to ensure that the user event will be next in the queue.
Frank Praznik 2 天之前
父節點
當前提交
ac82534375
共有 1 個文件被更改,包括 3 次插入0 次删除
  1. 3 0
      test/testautomation_events.c

+ 3 - 0
test/testautomation_events.c

@@ -287,6 +287,9 @@ static int SDLCALL events_mainThreadCallbacks(void *arg)
         SDL_WaitThread(thread, NULL);
         SDLTest_AssertCheck(data.counter == 3, "Incremented counter on main thread, expected 3, got %d", data.counter);
 
+        /* Flush events again, as the previous SDL_WaitEvent() call may have pumped OS events and added them to the queue */
+        SDL_FlushEvents(SDL_EVENT_FIRST, SDL_EVENT_LAST);
+
         /* Try again, but this time delay the calls until we've started waiting for events */
         data.delay = 100;
         thread = SDL_CreateThread(IncrementCounterThread, NULL, &data);