From 282ebdc0c6ac803b0f839b02779cd52ae9d9b3e7 Mon Sep 17 00:00:00 2001 From: Nobuhiko Tanibata Date: Tue, 3 Jun 2014 14:58:00 +0900 Subject: Avoid insertion of link_layer duplicate. Signed-off-by: Nobuhiko Tanibata --- ivi-shell/ivi-layout.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/ivi-shell/ivi-layout.c b/ivi-shell/ivi-layout.c index af84eb63..cb1b72b4 100644 --- a/ivi-shell/ivi-layout.c +++ b/ivi-shell/ivi-layout.c @@ -251,8 +251,20 @@ static void add_link_to_surface(struct ivi_layout_layer *ivilayer, struct link_layer *link_layer) { - wl_list_init(&link_layer->link_to_layer); - wl_list_insert(&ivilayer->link_to_surface, &link_layer->link_to_layer); + struct link_layer *link = NULL; + int found = 0; + + wl_list_for_each(link, &ivilayer->link_to_surface, link_to_layer) { + if (link == link_layer) { + found = 1; + break; + } + } + + if (found == 0) { + wl_list_init(&link_layer->link_to_layer); + wl_list_insert(&ivilayer->link_to_surface, &link_layer->link_to_layer); + } } static void -- cgit v1.2.1