@samitouri / QOSamiQemu / commits / 48b29d9eaa

ui/cocoa: implement display cleanup

Move cbowner release from QemuCocoaAppController -dealloc to cocoa_display_cleanup(), since cbowner is allocated in cocoa_display_init() and cleanup is the symmetric teardown path. Tested-by: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp> 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-20-4656aec3398d@redhat.com>

Marc-André Lureau committed Jun 23, 2026 at 11:44 UTC 48b29d9eaa7f71c7e44cba71b0e796eb9c774b65
1 file changed +17 -2
ui/cocoa.m
+17 -2
@@ -1206,8 +1206,6 @@ static CGEventRef handleTapEvent(CGEventTapProxy proxy, CGEventType type, CGEven
1206 COCOA_DEBUG("QemuCocoaAppController: dealloc\n");
1207
1208 [cocoaView release];
1209 - [cbowner release];
1210 - cbowner = nil;
1209
1210 [super dealloc];
1211 }
@@ -2038,9 +2036,26 @@ static void cocoa_display_init(DisplayState *ds, DisplayOptions *opts)
2036 qemu_main = cocoa_main;
2037 }
2038
2039 +static void cocoa_display_cleanup(void)
2040 +{
2041 + if (!kbd) {
2042 + return;
2043 + }
2044 +
2045 + qemu_console_unregister_listener(&dcl);
2046 + g_clear_pointer(&kbd, qkbd_state_free);
2047 + qemu_remove_mouse_mode_change_notifier(&mouse_mode_change_notifier);
2048 + qemu_clipboard_peer_unregister(&cbpeer);
2049 + g_clear_pointer(&cbinfo, qemu_clipboard_info_unref);
2050 + qemu_event_destroy(&cbevent);
2051 + [cbowner release];
2052 + cbowner = nil;
2053 +}
2054 +
2055 static QemuDisplay qemu_display_cocoa = {
2056 .type = DISPLAY_TYPE_COCOA,
2057 .init = cocoa_display_init,
2058 + .cleanup = cocoa_display_cleanup,
2059 };
2060
2061 static void register_cocoa(void)