aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2010-04-14 16:50:43 -0500
committerTed Gould <ted@gould.cx>2010-04-14 16:50:43 -0500
commit19dfb9380fc86a873a30a8c748c78689a2bf6d33 (patch)
treef79f145d10d2160b9bd744768e2c09d231265df6
parent3dbca0954d9f02df4c9a45a2d4573000d5b4a622 (diff)
downloadlibdbusmenu-19dfb9380fc86a873a30a8c748c78689a2bf6d33.tar.gz
libdbusmenu-19dfb9380fc86a873a30a8c748c78689a2bf6d33.tar.bz2
libdbusmenu-19dfb9380fc86a873a30a8c748c78689a2bf6d33.zip
Fail if we add a child to a menu that already has that child.
-rw-r--r--libdbusmenu-glib/menuitem.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c
index fce8ed5..2b4f9ca 100644
--- a/libdbusmenu-glib/menuitem.c
+++ b/libdbusmenu-glib/menuitem.c
@@ -533,6 +533,8 @@ dbusmenu_menuitem_child_append (DbusmenuMenuitem * mi, DbusmenuMenuitem * child)
g_return_val_if_fail(DBUSMENU_IS_MENUITEM(child), FALSE);
DbusmenuMenuitemPrivate * priv = DBUSMENU_MENUITEM_GET_PRIVATE(mi);
+ g_return_val_if_fail(g_list_find(priv->children, child), FALSE);
+
priv->children = g_list_append(priv->children, child);
#ifdef MASSIVEDEBUGGING
g_debug("Menuitem %d (%s) signalling child added %d (%s) at %d", ID(mi), LABEL(mi), ID(child), LABEL(child), g_list_length(priv->children) - 1);
@@ -558,6 +560,8 @@ dbusmenu_menuitem_child_prepend (DbusmenuMenuitem * mi, DbusmenuMenuitem * child
g_return_val_if_fail(DBUSMENU_IS_MENUITEM(child), FALSE);
DbusmenuMenuitemPrivate * priv = DBUSMENU_MENUITEM_GET_PRIVATE(mi);
+ g_return_val_if_fail(g_list_find(priv->children, child), FALSE);
+
priv->children = g_list_prepend(priv->children, child);
#ifdef MASSIVEDEBUGGING
g_debug("Menuitem %d (%s) signalling child added %d (%s) at %d", ID(mi), LABEL(mi), ID(child), LABEL(child), 0);
@@ -611,6 +615,8 @@ dbusmenu_menuitem_child_add_position (DbusmenuMenuitem * mi, DbusmenuMenuitem *
g_return_val_if_fail(DBUSMENU_IS_MENUITEM(child), FALSE);
DbusmenuMenuitemPrivate * priv = DBUSMENU_MENUITEM_GET_PRIVATE(mi);
+ g_return_val_if_fail(g_list_find(priv->children, child), FALSE);
+
priv->children = g_list_insert(priv->children, child, position);
#ifdef MASSIVEDEBUGGING
g_debug("Menuitem %d (%s) signalling child added %d (%s) at %d", ID(mi), LABEL(mi), ID(child), LABEL(child), position);