aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libtopmenu-client/topmenu-client.c10
-rw-r--r--libtopmenu-server/topmenu-server.c4
2 files changed, 10 insertions, 4 deletions
diff --git a/libtopmenu-client/topmenu-client.c b/libtopmenu-client/topmenu-client.c
index 63e27bc..771920e 100644
--- a/libtopmenu-client/topmenu-client.c
+++ b/libtopmenu-client/topmenu-client.c
@@ -82,6 +82,10 @@ void topmenu_client_connect_window_widget(GdkWindow *window, GtkWidget *widget)
G_CALLBACK(handle_widget_button_event), plug, 0);
gtk_widget_show(GTK_WIDGET(plug));
+ // Gtk+ should keep a reference to plug as it is a "top level" widget.
+ // Otherwise I failed to parse the documentation.
+ g_warn_if_fail(G_OBJECT(plug)->ref_count == 1);
+
Window plug_xwin = gtk_plug_get_id(plug);
Atom atom = XInternAtom(display, ATOM_TOPMENU_WINDOW, False);
@@ -90,7 +94,8 @@ void topmenu_client_connect_window_widget(GdkWindow *window, GtkWidget *widget)
XA_WINDOW, 32, PropModeReplace,
(unsigned char*)&plug_xwin, 1);
- g_object_set_data_full(G_OBJECT(window), OBJECT_DATA_KEY_PLUG, plug, (GDestroyNotify)&gtk_widget_destroy);
+ g_object_set_data_full(G_OBJECT(window), OBJECT_DATA_KEY_PLUG, plug,
+ (GDestroyNotify) &gtk_widget_destroy);
}
void topmenu_client_disconnect_window(GdkWindow *window)
@@ -109,5 +114,6 @@ void topmenu_client_disconnect_window(GdkWindow *window)
XDeleteProperty(display, xwin, atom);
- g_object_unref(plug);
+ g_warn_if_fail(G_OBJECT(plug)->ref_count == 1);
+ gtk_widget_destroy(plug);
}
diff --git a/libtopmenu-server/topmenu-server.c b/libtopmenu-server/topmenu-server.c
index a907d47..f9d7918 100644
--- a/libtopmenu-server/topmenu-server.c
+++ b/libtopmenu-server/topmenu-server.c
@@ -66,8 +66,8 @@ void topmenu_server_register_server_widget(GtkWidget *widget)
stub_attr.override_redirect = TRUE;
GdkWindow *stub = gdk_window_new(window, &stub_attr, GDK_WA_NOREDIR);
- g_object_set_data_full(G_OBJECT(widget), OBJECT_DATA_KEY_SERVER_STUB,
- stub, (GDestroyNotify)gdk_window_destroy);
+ g_object_set_data_full(G_OBJECT(widget), OBJECT_DATA_KEY_SERVER_STUB, stub,
+ (GDestroyNotify) &gdk_window_destroy);
server_widgets = g_list_prepend(server_widgets, widget);
update_selection_owner(GDK_CURRENT_TIME);