genlist : support synchronized deletion in item select for compatibility safety
authorSangHyeon Jade Lee <sh10233.lee@samsung.com>
Tue, 26 May 2020 10:30:40 +0000 (19:30 +0900)
committerJongmin Lee <jm105.lee@samsung.com>
Mon, 1 Jun 2020 04:45:20 +0000 (13:45 +0900)
in tizen 4.0
all deletions are synchronized,
so user might write the code with expecting item is deleted by API call
immediately.

in tizen 5.5
we keep the object reference and defer the efl_del of item object in
special case that it has to alive,
and this action may broken backward compatibility for some application,
which is wrote wrong expectation,
but still we have to support them.

this code is fallback the tizen 4.0 deletion process.
item is referenced by efl_ref() while select callback is processing,
but internal item deletion is happen immediately,
and only the object itself is alive till we call efl_unref().

it is only activated by ignore_ref flag up,
for applying genlist tizen only.

Change-Id: I89e2645823bf603c084a2c2df7feb518798b2a36

src/lib/elementary/elm_main.c
src/lib/elementary/elm_widget.h
src/lib/elementary_tizen/elm_genlist.c

index c5ed41c..ceddbea 100644 (file)
@@ -2148,15 +2148,21 @@ EAPI void
 elm_object_item_del(Eo *obj)
 {
    Elm_Widget_Item_Data *item;
+   //TIZEN_ONLY(20200526) : synchronized item deletion for tizen 4.0 compatibility.
+   item = efl_data_scope_safe_get(obj, ELM_WIDGET_ITEM_CLASS);
 
-   if (efl_ref_count(obj) == 1)
+   //if (efl_ref_count(obj) == 1)
+   if ((efl_ref_count(obj) == 1) || (item && item->ignore_ref))
+   //
      {
         // Noref already, die little item !
         efl_del(obj);
         return ;
      }
 
-   item = efl_data_scope_safe_get(obj, ELM_WIDGET_ITEM_CLASS);
+   //TIZEN_ONLY(20200526) : synchronized item deletion for tizen 4.0 compatibility.
+   //item = efl_data_scope_safe_get(obj, ELM_WIDGET_ITEM_CLASS);
+   //
    if (!item) return ;
    efl_event_callback_add(obj, EFL_EVENT_NOREF, _item_noref, NULL);
    item->on_deletion = EINA_TRUE;
index 5e8c499..bfbdf6a 100644 (file)
@@ -702,6 +702,9 @@ struct _Elm_Widget_Item_Data
    ///TIZEN_ONLY(20170717) : expose highlight information on atspi
    Eina_Bool                      can_highlight : 1; /**< true if widget have at-spi HIGHLIGHTABLE state */
    ///
+   //TIZEN_ONLY(20200526) : synchronized item deletion for tizen 4.0 compatibility.
+   Eina_Bool                      ignore_ref : 1;
+   //
 };
 
 #define ELM_NEW(t) calloc(1, sizeof(t))
index 270e95c..928c310 100644 (file)
@@ -1587,7 +1587,10 @@ _elm_genlist_scroll_item_align_highlight_cb(Evas_Object *obj, void *data EINA_UN
                {
                   sd->aligned_item->func.func((void *)sd->aligned_item->func.data, obj, EO_OBJ(sd->aligned_item));
                }
-             if (sd->aligned_item && !(sd->aligned_item->base->on_deletion))
+             //TIZEN_ONLY(20200526) : synchronized item deletion for tizen 4.0 compatibility.
+             //if (sd->aligned_item && !(sd->aligned_item->base->on_deletion)))
+             if (!efl_invalidated_get(aligned) && sd->aligned_item)
+             //
                {
                   evas_object_smart_callback_call(obj, SIG_SELECTED, EO_OBJ(sd->aligned_item));
                }
@@ -3956,6 +3959,9 @@ _item_select(Elm_Gen_Item *it)
    Evas_Object *obj = WIDGET(it);
    Elm_Genlist_Data *sd = GL_IT(it)->wsd;
    Eina_Bool r = EINA_FALSE;
+   //TIZEN_ONLY(20200526) : synchronized item deletion for tizen 4.0 compatibility.
+   Evas_Object *eo_it = EO_OBJ(it);
+   //
 
    if (elm_wdg_item_disabled_get(EO_OBJ(it))) return EINA_FALSE;
    if (_is_no_select(it) || (it->decorate_it_set)) return EINA_FALSE;
@@ -4022,7 +4028,10 @@ _item_select(Elm_Gen_Item *it)
      }
    //
    evas_object_ref(obj);
-   efl_ref(EO_OBJ(it));
+   //TIZEN_ONLY(20200526) : synchronized item deletion for tizen 4.0 compatibility.
+   //efl_ref(EO_OBJ(it));
+   efl_ref(eo_it);
+   //
 
 
    //TIZEN_ONLY(27Mar2020): Unfreeze event fix
@@ -4033,21 +4042,30 @@ _item_select(Elm_Gen_Item *it)
    //
 
    if (it->func.func) it->func.func((void *)it->func.data, obj, EO_OBJ(it));
-   if ((it->base)->on_deletion)
+   //TIZEN_ONLY(20200526) : synchronized item deletion for tizen 4.0 compatibility.
+   //if ((it->base)->on_deletion)
+   if (efl_invalidated_get(eo_it))
+   //
      {
         r = EINA_TRUE;
         goto item_deleted;
      }
 
    evas_object_smart_callback_call(WIDGET(it), SIG_SELECTED, EO_OBJ(it));
-   if ((it->base)->on_deletion)
+   //TIZEN_ONLY(20200526) : synchronized item deletion for tizen 4.0 compatibility.
+   //if ((it->base)->on_deletion)
+   if (efl_invalidated_get(eo_it))
      {
+   //
         r = EINA_TRUE;
         goto item_deleted;
      }
 
 item_deleted:
-   efl_unref(EO_OBJ(it));
+   //TIZEN_ONLY(20200526) : synchronized item deletion for tizen 4.0 compatibility.
+   //efl_unref(EO_OBJ(it));
+   efl_unref(eo_it);
+   //
    evas_object_unref(obj);
    return r;
 }
@@ -5911,6 +5929,9 @@ _item_mouse_move_cb(void *data,
    Evas_Event_Mouse_Move *ev = event_info;
    Elm_Gen_Item *it = data;
    Elm_Genlist_Data *sd = GL_IT(it)->wsd;
+   //TIZEN_ONLY(20200526) : synchronized item deletion for tizen 4.0 compatibility.
+   Evas_Object *eo_it = EO_OBJ(it);
+   //
 
    if (!it->down) return;
 
@@ -5975,7 +5996,10 @@ _item_mouse_move_cb(void *data,
    //*******************************
 
    evas_object_ref(obj);
-   efl_ref(EO_OBJ(it));
+   //TIZEN_ONLY(20200526) : synchronized item deletion for tizen 4.0 compatibility.
+   //efl_ref(EO_OBJ(it));
+   efl_ref(eo_it);
+   //
 
    if (!it->dragging)
      {
@@ -6018,13 +6042,19 @@ _item_mouse_move_cb(void *data,
      }
 
    /* If item magic value is changed, do not call smart callback*/
-   if (!((it->base)->on_deletion))
+   //TIZEN_ONLY(20200526) : synchronized item deletion for tizen 4.0 compatibility.
+   //if (!((it->base)->on_deletion))
+   if (!efl_invalidated_get(eo_it))
+   //
      {
         if (it->dragging)
           evas_object_smart_callback_call(WIDGET(it), SIG_DRAG, EO_OBJ(it));
      }
 
-   efl_unref(EO_OBJ(it));
+   //TIZEN_ONLY(20200526) : synchronized item deletion for tizen 4.0 compatibility.
+   //efl_unref(EO_OBJ(it));
+   efl_unref(eo_it);
+   //
    evas_object_unref(obj);
 }
 
@@ -8567,6 +8597,10 @@ _elm_genlist_item_new(Elm_Genlist_Data *sd,
    GL_IT(it)->align = EINA_TRUE;
    //
 
+   //TIZEN_ONLY(20200526) : synchronized item deletion for tizen 4.0 compatibility.
+   (it->base)->ignore_ref = EINA_TRUE;
+   //
+
    if (it->parent)
      {
         if (GL_IT(it->parent)->type == ELM_GENLIST_ITEM_GROUP)