Skip to content

Route SDL_QUIT as a close request on every open window - #2100

Open
Tutez64 wants to merge 1 commit into
openfl:developfrom
Tutez64:bugfix/sdl-quit-as-window-close
Open

Tutez64 wants to merge 1 commit into
openfl:developfrom
Tutez64:bugfix/sdl-quit-as-window-close

Conversation

@Tutez64

@Tutez64 Tutez64 commented Sep 16, 2026

Copy link
Copy Markdown
Contributor
  • SDL raises SDL_QUIT for application-external exits (SIGTERM/SIGINT via its default handlers, Cmd+Q on macOS). The SDL backend treated that as active = false, so the loop stopped, Quit() tore SDL down, and only then did lime_application_exec return and dispatch Application.onExit.
  • That skipped Window.onClose entirely. onExit is documented as cancelable, but by then it could not cancel anything. OpenFL's NativeApplication "exiting" (emitted from __checkForAllWindowsClosed) never fired either, so AIR-style shutdown and preventDefault() did not work on those paths.
  • Route SDL_QUIT as a WINDOW_CLOSE on every registered window (iterate a copy, since close unregisters). Stop the loop only when no window is open; SDL also raises SDL_QUIT after the last window is destroyed.

Stopping the loop on SIGTERM, SIGINT, or Cmd+Q skipped Window.onClose and Application.onExit, so those events were neither dispatched nor cancelable. Fall back to stopping only when no window is open.

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant