efl_ui_grid: fixup pack APIs
authorMarcel Hollerbach <mail@marcel-hollerbach.de>
Wed, 24 Apr 2019 15:56:35 +0000 (17:56 +0200)
committerWoochanlee <wc0917.lee@samsung.com>
Tue, 30 Apr 2019 01:03:02 +0000 (10:03 +0900)
the APIs in pack should only allow a single registeration of a item.
And when this item is registered, the parent should be set accordingly.

Reviewed-by: SangHyeon Jade Lee <sh10233.lee@samsung.com>
Differential Revision: https://phab.enlightenment.org/D8702

src/lib/elementary/efl_ui_grid.c

index 8e40f1c..ebc1a5a 100644 (file)
@@ -933,6 +933,15 @@ _grid_item_process(Eo *obj, Efl_Ui_Grid_Data *pd, EINA_UNUSED Efl_Ui_Grid_Item *
 {
    EFL_UI_GRID_ITEM_CHECK_OR_RETURN(it, EINA_FALSE);
 
+   if (eina_list_data_find(pd->items, it))
+     {
+        ERR("Item already added to this container!");
+        return EINA_FALSE;
+     }
+
+   if (!efl_ui_widget_sub_object_add(obj, it))
+     return EINA_FALSE;
+
    //FIXME: This is tricky workaround for set select mode and parent value.
    EFL_UI_GRID_ITEM_DATA_GET_OR_RETURN(it, gd, EINA_FALSE);
    EFL_UI_ITEM_DATA_GET_OR_RETURN(it, id, EINA_FALSE);