From 19dfb9380fc86a873a30a8c748c78689a2bf6d33 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 14 Apr 2010 16:50:43 -0500 Subject: Fail if we add a child to a menu that already has that child. --- libdbusmenu-glib/menuitem.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'libdbusmenu-glib') 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); -- cgit v1.2.3