diff options
author | Ted Gould <ted@canonical.com> | 2009-08-27 09:00:56 -0500 |
---|---|---|
committer | Ted Gould <ted@canonical.com> | 2009-08-27 09:00:56 -0500 |
commit | 0b3053b799eab488746383a2aadfe20c015a051c (patch) | |
tree | ea9d7cd0e44afb251a749a0ad58bab35ed90663c | |
parent | c05db6674b1ca087fce872b318e086c2b0a08679 (diff) | |
parent | 9e5b9b3ce66ff01c8395ea28bc227bb34cb50f8e (diff) | |
download | libdbusmenu-0b3053b799eab488746383a2aadfe20c015a051c.tar.gz libdbusmenu-0b3053b799eab488746383a2aadfe20c015a051c.tar.bz2 libdbusmenu-0b3053b799eab488746383a2aadfe20c015a051c.zip |
Changes from Neil's code review.
-rw-r--r-- | debian/changelog | 6 | ||||
-rw-r--r-- | libdbusmenu-glib/client.c | 17 | ||||
-rw-r--r-- | libdbusmenu-gtk/client.c | 22 | ||||
-rw-r--r-- | libdbusmenu-gtk/menu.c | 2 |
4 files changed, 38 insertions, 9 deletions
diff --git a/debian/changelog b/debian/changelog index 038a86f..ae35a02 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +libdbusmenu (0.0.2-0ubuntu1~ppa5) UNRELEASED; urgency=low + + * Changes from Neil's code review. + + -- Ted Gould <ted@ubuntu.com> Thu, 27 Aug 2009 09:00:43 -0500 + libdbusmenu (0.0.2-0ubuntu1~ppa4) karmic; urgency=low * Public accessor for the GtkMenu's client diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index ffde8e3..dd2254e 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -537,6 +537,8 @@ menuitem_get_properties_cb (DBusGProxy * proxy, GHashTable * properties, GError static void menuitem_get_properties_new_cb (DBusGProxy * proxy, GHashTable * properties, GError * error, gpointer data) { + g_return_if_fail(data != NULL); + newItemPropData * propdata = (newItemPropData *)data; DbusmenuClientPrivate * priv = DBUSMENU_CLIENT_GET_PRIVATE(propdata->client); @@ -620,11 +622,15 @@ parse_layout_xml(DbusmenuClient * client, xmlNodePtr node, DbusmenuMenuitem * it /* Get the properties queued up for this item */ /* Not happy about this, but I need these :( */ newItemPropData * propdata = g_new0(newItemPropData, 1); - propdata->client = client; - propdata->item = item; - propdata->parent = parent; - - org_freedesktop_dbusmenu_get_properties_async(proxy, id, menuitem_get_properties_new_cb, propdata); + if (propdata != NULL) { + propdata->client = client; + propdata->item = item; + propdata->parent = parent; + + org_freedesktop_dbusmenu_get_properties_async(proxy, id, menuitem_get_properties_new_cb, propdata); + } else { + g_warning("Unable to allocate memory to get properties for menuitem. This menuitem will never be realized."); + } } xmlNodePtr children; @@ -830,6 +836,7 @@ gboolean dbusmenu_client_add_type_handler (DbusmenuClient * client, const gchar * type, DbusmenuClientTypeHandler newfunc) { g_return_val_if_fail(DBUSMENU_IS_CLIENT(client), FALSE); + g_return_val_if_fail(type != NULL, FALSE); DbusmenuClientPrivate * priv = DBUSMENU_CLIENT_GET_PRIVATE(client); diff --git a/libdbusmenu-gtk/client.c b/libdbusmenu-gtk/client.c index 54db5db..7271c37 100644 --- a/libdbusmenu-gtk/client.c +++ b/libdbusmenu-gtk/client.c @@ -287,11 +287,18 @@ dbusmenu_gtkclient_menuitem_get (DbusmenuGtkClient * client, DbusmenuMenuitem * static gboolean new_item_normal (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client) { - GtkMenuItem * gmi; + g_return_val_if_fail(DBUSMENU_IS_MENUITEM(newitem), FALSE); + g_return_val_if_fail(DBUSMENU_IS_GTKCLIENT(client), FALSE); + /* Note: not checking parent, it's reasonable for it to be NULL */ + GtkMenuItem * gmi; gmi = GTK_MENU_ITEM(gtk_menu_item_new_with_label(dbusmenu_menuitem_property_get(newitem, DBUSMENU_MENUITEM_PROP_LABEL))); - dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client), newitem, gmi, parent); + if (gmi != NULL) { + dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client), newitem, gmi, parent); + } else { + return FALSE; + } return TRUE; } @@ -299,11 +306,18 @@ new_item_normal (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbusmenu static gboolean new_item_seperator (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client) { - GtkMenuItem * gmi; + g_return_val_if_fail(DBUSMENU_IS_MENUITEM(newitem), FALSE); + g_return_val_if_fail(DBUSMENU_IS_GTKCLIENT(client), FALSE); + /* Note: not checking parent, it's reasonable for it to be NULL */ + GtkMenuItem * gmi; gmi = GTK_MENU_ITEM(gtk_separator_menu_item_new()); - dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client), newitem, gmi, parent); + if (gmi != NULL) { + dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client), newitem, gmi, parent); + } else { + return FALSE; + } return TRUE; } diff --git a/libdbusmenu-gtk/menu.c b/libdbusmenu-gtk/menu.c index 92cd13b..74e1bec 100644 --- a/libdbusmenu-gtk/menu.c +++ b/libdbusmenu-gtk/menu.c @@ -215,6 +215,8 @@ root_child_delete (DbusmenuMenuitem * root, DbusmenuMenuitem * child, DbusmenuGt static void child_realized (DbusmenuMenuitem * child, gpointer userdata) { + g_return_if_fail(DBUSMENU_IS_GTKMENU(userdata)); + DbusmenuGtkMenu * menu = DBUSMENU_GTKMENU(userdata); DbusmenuGtkMenuPrivate * priv = DBUSMENU_GTKMENU_GET_PRIVATE(menu); |