ivi-shell: bugfix, add ref_count to ivi_layout_layer
authorNobuhiko Tanibata <NOBUHIKO_TANIBATA@xddp.denso.co.jp>
Mon, 22 Jun 2015 06:31:16 +0000 (15:31 +0900)
committerPekka Paalanen <pekka.paalanen@collabora.co.uk>
Tue, 23 Jun 2015 12:57:15 +0000 (15:57 +0300)
if a controller calls ivi_layout_layer_create_with_demenstion with a ID
which is already created before, the API returns exist ivi_layer.
However addtionally, it shall count up ref count to destroy ivi_layer
when ref count is 0. The previous code will destroy ivi_layer
immediately even if the other code still refers ivi_layer.

Signed-off-by: Nobuhiko Tanibata <NOBUHIKO_TANIBATA@xddp.denso.co.jp>
Acked-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
ivi-shell/ivi-layout-private.h
ivi-shell/ivi-layout.c

index 8b6196306c05bdd63debdf04a80b6945b7822abc..cf2db7d56aa7568b07bfe54fe111da644a6e4124 100644 (file)
@@ -88,6 +88,8 @@ struct ivi_layout_layer {
                struct wl_list surface_list;
                struct wl_list link;
        } order;
+
+       int32_t ref_count;
 };
 
 struct ivi_layout {
index 079b3e3a9d0e322441dffc776c4705823e3ab6c0..d7108b6083aa607024cfdc4abf56d47dea65a746 100644 (file)
@@ -1820,6 +1820,7 @@ ivi_layout_layer_create_with_dimension(uint32_t id_layer,
        ivilayer = get_layer(&layout->layer_list, id_layer);
        if (ivilayer != NULL) {
                weston_log("id_layer is already created\n");
+               ++ivilayer->ref_count;
                return ivilayer;
        }
 
@@ -1829,6 +1830,7 @@ ivi_layout_layer_create_with_dimension(uint32_t id_layer,
                return NULL;
        }
 
+       ivilayer->ref_count = 1;
        wl_list_init(&ivilayer->link);
        wl_signal_init(&ivilayer->property_changed);
        wl_list_init(&ivilayer->screen_list);
@@ -1874,6 +1876,9 @@ ivi_layout_layer_remove(struct ivi_layout_layer *ivilayer)
                return;
        }
 
+       if (--ivilayer->ref_count > 0)
+               return;
+
        wl_signal_emit(&layout->layer_notification.removed, ivilayer);
 
        clear_surface_pending_list(ivilayer);