aboutsummaryrefslogtreecommitdiff
path: root/libtopmenu-client
diff options
context:
space:
mode:
authorJavier <dev.git@javispedro.com>2014-02-09 00:50:39 +0100
committerJavier <dev.git@javispedro.com>2014-02-09 00:50:39 +0100
commitcecc7efece527e09afdfb59dc24cbf6086bd2654 (patch)
treeb60dd1ce58e2256140b1a871709ebfa77ff3c5ad /libtopmenu-client
parentdfade684171c59f24ce3332703178fc0d73631fa (diff)
downloadtopmenu-gtk-cecc7efece527e09afdfb59dc24cbf6086bd2654.tar.gz
topmenu-gtk-cecc7efece527e09afdfb59dc24cbf6086bd2654.zip
improve client memory management warnings
Diffstat (limited to 'libtopmenu-client')
-rw-r--r--libtopmenu-client/topmenu-client.c10
1 files changed, 8 insertions, 2 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);
}