[elementary] Fixing list clearing inside item selection for
authorglima <glima@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Wed, 24 Aug 2011 21:03:37 +0000 (21:03 +0000)
committerglima <glima@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Wed, 24 Aug 2011 21:03:37 +0000 (21:03 +0000)
 genlists.
When the items are made invalid, don't access rotten pointers! I think
I did it right, but it exposes a bug on genlist test 2, elementary
test. I'll let that fix to the authors of that specific code
(insert_after() and such).

git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/elementary@62763 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

src/lib/elm_genlist.c

index 38bc776..3b09dae 100644 (file)
@@ -826,6 +826,8 @@ _item_del(Elm_Genlist_Item *it)
 static void
 _item_select(Elm_Genlist_Item *it)
 {
+   Evas_Object *parent = it->base.widget;
+
    if ((it->wd->no_select) || (it->delete_me) || (it->mode_view)) return;
    if (it->selected)
      {
@@ -835,25 +837,31 @@ _item_select(Elm_Genlist_Item *it)
    it->selected = EINA_TRUE;
    it->wd->selected = eina_list_append(it->wd->selected, it);
 call:
-   evas_object_ref(it->base.widget);
+   evas_object_ref(parent);
    it->walking++;
    it->wd->walking++;
-   if (it->func.func) it->func.func((void *)it->func.data, it->base.widget, it);
+   if (it->func.func) it->func.func((void *)it->func.data, parent, it);
    if (!it->delete_me)
-     evas_object_smart_callback_call(it->base.widget, SIG_SELECTED, it);
+     evas_object_smart_callback_call(parent, SIG_SELECTED, it);
    it->walking--;
    it->wd->walking--;
    if ((it->wd->clear_me) && (!it->wd->walking))
-     elm_genlist_clear(it->base.widget);
+     {
+        elm_genlist_clear(parent);
+        goto end;
+     }
    else
      {
         if ((!it->walking) && (it->delete_me))
           {
              if (!it->relcount) _item_del(it);
+             goto end;
           }
      }
    it->wd->last_selected_item = it;
-   evas_object_unref(it->base.widget);
+
+end:
+   evas_object_unref(parent);
 }
 
 static void