zmike pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=7d16c344c17a81e268d8d0bd945444b73487631b

commit 7d16c344c17a81e268d8d0bd945444b73487631b
Author: Cedric BAIL <[email protected]>
Date:   Tue Dec 24 09:20:11 2019 -0500

    elementary: enforce container type check for efl_ui_item_index_get and 
improve documentation.
    
    Summary: Depends on D10927
    
    Reviewers: bu5hm4n, segfaultxavi, SanghyeonLee
    
    Reviewed By: SanghyeonLee
    
    Subscribers: zmike, #reviewers, #committers
    
    Tags: #efl
    
    Maniphest Tasks: T8351
    
    Differential Revision: https://phab.enlightenment.org/D10945
---
 src/lib/elementary/efl_ui_item.c  | 2 ++
 src/lib/elementary/efl_ui_item.eo | 6 +++++-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/lib/elementary/efl_ui_item.c b/src/lib/elementary/efl_ui_item.c
index 5d86dc934d..85b50ee758 100644
--- a/src/lib/elementary/efl_ui_item.c
+++ b/src/lib/elementary/efl_ui_item.c
@@ -147,6 +147,8 @@ _efl_ui_item_efl_object_destructor(Eo *obj, 
Efl_Ui_Item_Data *pd EINA_UNUSED)
 EOLIAN static int
 _efl_ui_item_index_get(const Eo *obj, Efl_Ui_Item_Data *pd)
 {
+   EINA_SAFETY_ON_NULL_RETURN_VAL(pd->container, -1);
+   EINA_SAFETY_ON_FALSE_RETURN_VAL(efl_isa(pd->container, 
EFL_PACK_LINEAR_INTERFACE), -1);
    return efl_pack_index_get(pd->container, obj);
 }
 
diff --git a/src/lib/elementary/efl_ui_item.eo 
b/src/lib/elementary/efl_ui_item.eo
index e692f12a74..016636dfa0 100644
--- a/src/lib/elementary/efl_ui_item.eo
+++ b/src/lib/elementary/efl_ui_item.eo
@@ -27,7 +27,11 @@ abstract Efl.Ui.Item extends Efl.Ui.Layout_Base implements 
Efl.Ui.Selectable, Ef
       @property index {
          [[The index of this item inside its container.
 
-           The container must be set through the @Efl.Ui.Item.container 
property.]]
+           The container must be set through the @Efl.Ui.Item.container 
property and be exposing an @Efl.Pack_Linear interface.
+           If the container is not an @Efl.Pack_Linear, -1 will be returned.
+
+           Finally, it is a very slow API that must not be used in any 
performance constrained case.
+         ]]
          get {}
          values {
             index : int; [[The index where to find this item in its 
@.container.]]

-- 


Reply via email to