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.
Signed-off-by: Marc-André Lureau <[email protected]> --- ui/cocoa.m | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/ui/cocoa.m b/ui/cocoa.m index c5e639ab98d..bd0c5c6ed9e 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -1331,8 +1331,6 @@ - (void) dealloc COCOA_DEBUG("QemuCocoaAppController: dealloc\n"); [cocoaView release]; - [cbowner release]; - cbowner = nil; [super dealloc]; } @@ -2163,9 +2161,26 @@ static void cocoa_display_init(DisplayState *ds, DisplayOptions *opts) qemu_main = cocoa_main; } +static void cocoa_display_cleanup(void) +{ + if (!kbd) { + return; + } + + qemu_console_unregister_listener(&dcl); + g_clear_pointer(&kbd, qkbd_state_free); + qemu_remove_mouse_mode_change_notifier(&mouse_mode_change_notifier); + qemu_clipboard_peer_unregister(&cbpeer); + g_clear_pointer(&cbinfo, qemu_clipboard_info_unref); + qemu_event_destroy(&cbevent); + [cbowner release]; + cbowner = nil; +} + static QemuDisplay qemu_display_cocoa = { .type = DISPLAY_TYPE_COCOA, .init = cocoa_display_init, + .cleanup = cocoa_display_cleanup, }; static void register_cocoa(void) -- 2.54.0
