Fri, 15 Nov 2024 21:25:35 +0100
add ui_dialog_window reference counting (GTK)
ui/gtk/window.c | file | annotate | diff | comparison | revisions |
--- a/ui/gtk/window.c Fri Nov 15 21:23:16 2024 +0100 +++ b/ui/gtk/window.c Fri Nov 15 21:25:35 2024 +0100 @@ -694,6 +694,8 @@ UiObject *obj = cxCalloc(mp->allocator, 1, sizeof(UiObject)); obj->ctx = uic_context(obj, mp); obj->widget = dialog; + obj->ref = 0; + obj->destroy = ui_window_widget_destroy; nwindows++; if(args.title != NULL) { @@ -721,6 +723,19 @@ "destroy", G_CALLBACK(ui_exit_event), obj); +#if GTK_MAJOR_VERSION >= 4 + g_signal_connect( + obj->widget, + "close-request", + G_CALLBACK(close_request), + obj); +#else + g_signal_connect( + obj->widget, + "delete-event", + G_CALLBACK(close_request), + obj); +#endif #if GTK_MAJOR_VERSION < 4 GtkWidget *c = gtk_dialog_get_content_area(GTK_DIALOG(dialog));