소스 검색

Make sure that we quit if we get a terminating event

This covers the case where the application didn't handle the quit or terminating event, we still need the main loop to finish.
Sam Lantinga 11 달 전
부모
커밋
a432abf4cc
1개의 변경된 파일5개의 추가작업 그리고 0개의 파일을 삭제
  1. 5 0
      src/main/SDL_main_callbacks.c

+ 5 - 0
src/main/SDL_main_callbacks.c

@@ -75,6 +75,11 @@ static bool SDLCALL SDL_MainCallbackEventWatcher(void *userdata, SDL_Event *even
         // Make sure any currently queued events are processed then dispatch this before continuing
         SDL_DispatchMainCallbackEvents();
         SDL_DispatchMainCallbackEvent(event);
+
+        // Make sure that we quit if we get a terminating event
+        if (event->type == SDL_EVENT_TERMINATING) {
+            SDL_CompareAndSwapAtomicInt(&apprc, SDL_APP_CONTINUE, SDL_APP_SUCCESS);
+        }
     } else {
         // We'll process this event later from the main event queue
     }