Skip to content

Commit 9bea616

Browse files
committed
SDLApplication: fix crash in SDL_Quit on Windows by calling SDL_QuitSubSystem first with the same flags passed to SDL_Init (closes openfl#1934)
As far as I can tell, SDL_QuitSubSystem is not required, and SDL_Quit should automatically quit each subsystem. However, this stops the crash, so maybe there's some kind of race condition that this avoids.
1 parent 48969a3 commit 9bea616

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

project/src/backend/sdl/SDLApplication.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ namespace lime {
2525

2626
SDLApplication::SDLApplication () {
2727

28-
Uint32 initFlags = SDL_INIT_VIDEO | SDL_INIT_GAMECONTROLLER | SDL_INIT_TIMER | SDL_INIT_JOYSTICK;
28+
initFlags = SDL_INIT_VIDEO | SDL_INIT_GAMECONTROLLER | SDL_INIT_TIMER | SDL_INIT_JOYSTICK;
2929
#if defined(LIME_MOJOAL) || defined(LIME_OPENALSOFT)
3030
initFlags |= SDL_INIT_AUDIO;
3131
#endif
@@ -814,6 +814,8 @@ namespace lime {
814814
applicationEvent.type = EXIT;
815815
ApplicationEvent::Dispatch (&applicationEvent);
816816

817+
SDL_QuitSubSystem (initFlags);
818+
817819
SDL_Quit ();
818820

819821
return 0;

project/src/backend/sdl/SDLApplication.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ namespace lime {
6363
ClipboardEvent clipboardEvent;
6464
Uint32 currentUpdate;
6565
double framePeriod;
66+
Uint32 initFlags;
6667
DropEvent dropEvent;
6768
GamepadEvent gamepadEvent;
6869
JoystickEvent joystickEvent;

0 commit comments

Comments
 (0)