From ade76d21e26083ebd287564c321ee3a7600d1fe4 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 1 Oct 2009 15:34:26 -0500 Subject: Leaving abstract the data as long as possible to avoid GTK cast warnings. --- libdbusmenu-gtk/client.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/libdbusmenu-gtk/client.c b/libdbusmenu-gtk/client.c index 35f5e61..21da38e 100644 --- a/libdbusmenu-gtk/client.c +++ b/libdbusmenu-gtk/client.c @@ -324,14 +324,13 @@ dbusmenu_gtkclient_menuitem_get (DbusmenuGtkClient * client, DbusmenuMenuitem * g_return_val_if_fail(DBUSMENU_IS_GTKCLIENT(client), NULL); g_return_val_if_fail(DBUSMENU_IS_MENUITEM(item), NULL); - GtkMenuItem * mi = GTK_MENU_ITEM(g_object_get_data(G_OBJECT(item), data_menuitem)); - if (mi == NULL) { - // new_menuitem(DBUSMENU_CLIENT(client), item, NULL); + gpointer data = g_object_get_data(G_OBJECT(item), data_menuitem); + if (data == NULL) { g_warning("GTK not updated"); - mi = GTK_MENU_ITEM(g_object_get_data(G_OBJECT(item), data_menuitem)); + return NULL; } - return mi; + return GTK_MENU_ITEM(data); } /* The base type handler that builds a plain ol' -- cgit v1.2.3 From d0e28d7c6e98d91fc14398ea863bb378eb9cc9c7 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 1 Oct 2009 15:34:38 -0500 Subject: Checking to see if we got null before casting. --- libdbusmenu-gtk/menu.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libdbusmenu-gtk/menu.c b/libdbusmenu-gtk/menu.c index ff473dc..8f97294 100644 --- a/libdbusmenu-gtk/menu.c +++ b/libdbusmenu-gtk/menu.c @@ -196,8 +196,9 @@ root_child_added (DbusmenuMenuitem * root, DbusmenuMenuitem * child, guint posit g_signal_connect(G_OBJECT(child), DBUSMENU_MENUITEM_SIGNAL_REALIZED, G_CALLBACK(child_realized), menu); - GtkWidget * item = GTK_WIDGET(dbusmenu_gtkclient_menuitem_get(priv->client, child)); - if (item != NULL) { + GtkMenuItem * mi = dbusmenu_gtkclient_menuitem_get(priv->client, child); + if (mi != NULL) { + GtkWidget * item = GTK_WIDGET(mi); gtk_menu_append(GTK_MENU(menu), item); gtk_menu_reorder_child(GTK_MENU(menu), item, dbusmenu_menuitem_get_position(root, child)); } -- cgit v1.2.3