genlist: fix a crash when deleting a item in selected callback.
authorChunEon Park <hermet@hermet.pe.kr>
Wed, 14 Jan 2015 14:30:43 +0000 (23:30 +0900)
committerChunEon Park <hermet@hermet.pe.kr>
Wed, 14 Jan 2015 14:30:43 +0000 (23:30 +0900)
if user deletes the item in the callback,
current function(_item_select) would be corrupted.
just leave the callback call in the last of the function.

src/lib/elm_genlist.c

index a4ebbf8..81d6246 100644 (file)
@@ -5669,9 +5669,6 @@ _item_select(Elm_Gen_Item *it)
           eina_list_append(sd->selected, eo_it);
      }
 
-   evas_object_ref(obj);
-   if (it->func.func) it->func.func((void *)it->func.data, WIDGET(it), eo_it);
-   evas_object_smart_callback_call(WIDGET(it), SIG_SELECTED, eo_it);
    elm_object_item_focus_set(eo_it, EINA_TRUE);
    _elm_genlist_item_content_focus_set(it, ELM_FOCUS_PREVIOUS);
 
@@ -5692,6 +5689,12 @@ _item_select(Elm_Gen_Item *it)
           }
      }
 
+   evas_object_ref(obj);
+
+   if (it->func.func) it->func.func((void *)it->func.data, WIDGET(it), eo_it);
+   if (EINA_MAGIC_CHECK((Elm_Widget_Item_Data *)it, ELM_WIDGET_ITEM_MAGIC))
+     evas_object_smart_callback_call(WIDGET(it), SIG_SELECTED, eo_it);
+
    evas_object_unref(obj);
 }