list: initialize some internal variables on item free not item del pre.
authorDaniel Juyung Seo <seojuyung2@gmail.com>
Sat, 10 May 2014 14:37:03 +0000 (23:37 +0900)
committerDaniel Juyung Seo <seojuyung2@gmail.com>
Sat, 10 May 2014 14:44:28 +0000 (23:44 +0900)
This fixes variable initialize problems related to focus. This can be
reproduced when you enable focus highlight/animation and reuse
elm_list by clearing it.

This problem occurred because list item del pre is never been called.
This bug will be addressed in a next commit.

legacy/elementary/src/lib/elm_list.c

index 0508978..dedc4a1 100644 (file)
@@ -73,6 +73,18 @@ static const Elm_Action key_actions[] = {
 static inline void
 _elm_list_item_free(Elm_List_Item *it)
 {
+   ELM_LIST_DATA_GET(WIDGET(it), sd);
+
+   if (sd->focused_item == (Elm_Object_Item *)it)
+     sd->focused_item = NULL;
+   if (sd->last_focused_item == (Elm_Object_Item *)it)
+     sd->last_focused_item = NULL;
+   if (sd->prev_focused_item == (Elm_Object_Item *)it)
+     sd->prev_focused_item = NULL;
+   if (sd->last_selected_item == (Elm_Object_Item *)it)
+     sd->last_selected_item = NULL;
+
+
    evas_object_event_callback_del_full
      (VIEW(it), EVAS_CALLBACK_MOUSE_DOWN, _mouse_down_cb, it);
    evas_object_event_callback_del_full
@@ -1881,15 +1893,6 @@ _item_del_pre_hook(Elm_Object_Item *it)
 
    sd->items = eina_list_remove_list(sd->items, item->node);
 
-   if (sd->focused_item == (Elm_Object_Item *)it)
-     sd->focused_item = NULL;
-   if (sd->last_focused_item == (Elm_Object_Item *)it)
-     sd->last_focused_item = NULL;
-   if (sd->prev_focused_item == (Elm_Object_Item *)it)
-     sd->prev_focused_item = NULL;
-   if (sd->last_selected_item == (Elm_Object_Item *)it)
-     sd->last_selected_item = NULL;
-
    evas_object_ref(obj);
    _elm_list_walk(sd);