mirror of
https://github.com/qemu/qemu.git
synced 2026-07-08 17:56:38 +00:00
ui/sdl2: implement display cleanup
Replace the atexit() handler with a proper cleanup callback. Extend sdl_cleanup() to unregister display listeners, free keyboard state, destroy windows, and clean up all cursor resources. Reviewed-by: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-ID: <20260623-b4-ui-v4-17-4656aec3398d@redhat.com>
This commit is contained in:
23
ui/sdl2.c
23
ui/sdl2.c
@@ -790,9 +790,25 @@ static void sdl_mouse_define(DisplayChangeListener *dcl,
|
||||
|
||||
static void sdl_cleanup(void)
|
||||
{
|
||||
if (guest_sprite) {
|
||||
SDL_FreeCursor(guest_sprite);
|
||||
int i;
|
||||
|
||||
if (!sdl2_console) {
|
||||
return;
|
||||
}
|
||||
|
||||
qemu_remove_mouse_mode_change_notifier(&mouse_mode_notifier);
|
||||
|
||||
for (i = 0; i < sdl2_num_outputs; i++) {
|
||||
qemu_console_unregister_listener(&sdl2_console[i].dcl);
|
||||
qkbd_state_free(sdl2_console[i].kbd);
|
||||
sdl2_window_destroy(&sdl2_console[i]);
|
||||
}
|
||||
g_clear_pointer(&sdl2_console, g_free);
|
||||
sdl2_num_outputs = 0;
|
||||
|
||||
g_clear_pointer(&guest_sprite, SDL_FreeCursor);
|
||||
g_clear_pointer(&guest_sprite_surface, SDL_FreeSurface);
|
||||
g_clear_pointer(&sdl_cursor_hidden, SDL_FreeCursor);
|
||||
SDL_QuitSubSystem(SDL_INIT_VIDEO);
|
||||
}
|
||||
|
||||
@@ -998,8 +1014,6 @@ static void sdl2_display_init(DisplayState *ds, DisplayOptions *o)
|
||||
sdl_grab_start(&sdl2_console[0]);
|
||||
}
|
||||
|
||||
atexit(sdl_cleanup);
|
||||
|
||||
/* SDL's event polling (in dpy_refresh) must happen on the main thread. */
|
||||
qemu_main = NULL;
|
||||
}
|
||||
@@ -1008,6 +1022,7 @@ static QemuDisplay qemu_display_sdl2 = {
|
||||
.type = DISPLAY_TYPE_SDL,
|
||||
.early_init = sdl2_display_early_init,
|
||||
.init = sdl2_display_init,
|
||||
.cleanup = sdl_cleanup,
|
||||
};
|
||||
|
||||
static void register_sdl1(void)
|
||||
|
||||
Reference in New Issue
Block a user