diff options
author | Javier <dev.git@javispedro.com> | 2014-02-09 00:50:39 +0100 |
---|---|---|
committer | Javier <dev.git@javispedro.com> | 2014-02-09 00:50:39 +0100 |
commit | cecc7efece527e09afdfb59dc24cbf6086bd2654 (patch) | |
tree | b60dd1ce58e2256140b1a871709ebfa77ff3c5ad | |
parent | dfade684171c59f24ce3332703178fc0d73631fa (diff) | |
download | topmenu-gtk-cecc7efece527e09afdfb59dc24cbf6086bd2654.tar.gz topmenu-gtk-cecc7efece527e09afdfb59dc24cbf6086bd2654.zip |
improve client memory management warnings
-rw-r--r-- | libtopmenu-client/topmenu-client.c | 10 | ||||
-rw-r--r-- | libtopmenu-server/topmenu-server.c | 4 |
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)>k_widget_destroy); + g_object_set_data_full(G_OBJECT(window), OBJECT_DATA_KEY_PLUG, plug, + (GDestroyNotify) >k_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); |