Explicitly shutdown the SDL_INIT_EVENTS subsystem.

SDL_INIT_VIDEO includes SDL_INIT_EVENTS when initialized through
SDL_Init(), but not when shutdown to SDL_Quit(). Handle the shutdown
in the input subsystem. This closes some memory leaks in SDL.
This commit is contained in:
Yamagi 2024-03-31 10:44:16 +02:00
parent 5a21397761
commit adfd7362b5
2 changed files with 11 additions and 6 deletions

View file

@ -2310,6 +2310,14 @@ IN_Init(void)
Cmd_AddCommand("+gyroaction", IN_GyroActionDown);
Cmd_AddCommand("-gyroaction", IN_GyroActionUp);
if (!SDL_WasInit(SDL_INIT_EVENTS))
{
if ((SDL_InitSubSystem(SDL_INIT_EVENTS)) != 0)
{
Com_Error(ERR_FATAL, "Couldn't initialize SDL event subsystem:%s\n", SDL_GetError());
}
}
SDL_StartTextInput();
IN_Controller_Init(false);
@ -2379,9 +2387,11 @@ IN_Shutdown(void)
IN_Controller_Shutdown(false);
const Uint32 subsystems = SDL_INIT_GAMECONTROLLER | SDL_INIT_HAPTIC;
const Uint32 subsystems = SDL_INIT_GAMECONTROLLER | SDL_INIT_HAPTIC | SDL_INIT_EVENTS;
if (SDL_WasInit(subsystems) == subsystems)
{
SDL_QuitSubSystem(subsystems);
}
}
/* ------------------------------------------------------------------ */

View file

@ -451,11 +451,6 @@ void
GLimp_Shutdown(void)
{
ShutdownGraphics();
// TODO SDL3: SDL_INIT_VIDEO implies SDL_INIT_EVENTS
// in SDL 2 this was handled by SDL_INIT_EVERYTHING
// which is unavailable in SDL 3. Handle SDL_INIT_EVENTS
// in the input backend?
SDL_QuitSubSystem(SDL_INIT_VIDEO);
ClearDisplayIndices();
}