aboutsummaryrefslogtreecommitdiff
path: root/libdbusmenu-gtk
diff options
context:
space:
mode:
authorTed Gould <ted@canonical.com>2009-08-27 08:45:49 -0500
committerTed Gould <ted@canonical.com>2009-08-27 08:45:49 -0500
commit86b7b92f7f45eb77ce648a9fae5d48c3d0e02632 (patch)
treea21ba36d1158132e3cf7991117e78d61f2fff6c5 /libdbusmenu-gtk
parent84c3e9454452203fec2bbff80a25028391360aac (diff)
downloadlibdbusmenu-86b7b92f7f45eb77ce648a9fae5d48c3d0e02632.tar.gz
libdbusmenu-86b7b92f7f45eb77ce648a9fae5d48c3d0e02632.tar.bz2
libdbusmenu-86b7b92f7f45eb77ce648a9fae5d48c3d0e02632.zip
Adding checks to the type handling functions in GTK+ version of the lib. Comments by Neil.
Diffstat (limited to 'libdbusmenu-gtk')
-rw-r--r--libdbusmenu-gtk/client.c22
1 files changed, 18 insertions, 4 deletions
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;
}