@samitouri / QOSamiQemu / commits / b660cf2cab

ui/spice-app: implement display cleanup

Replace the atexit() handler with the display cleanup callback, reusing the existing spice_app_atexit() function. 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-18-4656aec3398d@redhat.com>

Marc-André Lureau committed Jun 23, 2026 at 11:44 UTC b660cf2cab2e65bb8c088654f49d4fb2622a6f77
1 file changed +5 -5
ui/spice-app.c
+5 -5
@@ -119,16 +119,17 @@ static const TypeInfo char_vc_type_info = {
119 .class_size = sizeof(VCChardevClass),
120 };
121
122 -static void spice_app_atexit(void)
122 +static void spice_app_cleanup(void)
123 {
124 if (sock_path) {
125 unlink(sock_path);
126 + g_clear_pointer(&sock_path, g_free);
127 }
128 if (tmp_dir) {
129 rmdir(tmp_dir);
130 + tmp_dir = NULL;
131 }
130 - g_free(sock_path);
131 - g_free(app_dir);
132 + g_clear_pointer(&app_dir, g_free);
133 }
134
135 static void spice_app_display_early_init(DisplayOptions *opts)
@@ -146,8 +147,6 @@ static void spice_app_display_early_init(DisplayOptions *opts)
147 exit(1);
148 }
149
149 - atexit(spice_app_atexit);
150 -
150 if (qemu_name) {
151 app_dir = g_build_filename(g_get_user_runtime_dir(),
152 "qemu", qemu_name, NULL);
@@ -218,6 +217,7 @@ static QemuDisplay qemu_display_spice_app = {
217 .type = DISPLAY_TYPE_SPICE_APP,
218 .early_init = spice_app_display_early_init,
219 .init = spice_app_display_init,
220 + .cleanup = spice_app_cleanup,
221 .vc = "vc",
222 };
223