elm genlist: Added more guard code and moved some codes for the
authorseoz <seoz@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Tue, 2 Aug 2011 06:54:10 +0000 (06:54 +0000)
committerseoz <seoz@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Tue, 2 Aug 2011 06:54:10 +0000 (06:54 +0000)
readability.

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

src/lib/elm_genlist.c

index b7c129b..4031c58 100644 (file)
@@ -3470,6 +3470,9 @@ elm_genlist_item_insert_before(Evas_Object                  *obj,
    Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
                                     func_data);
    if (!it) return NULL;
+   /* It makes no sense to insert before in an empty list with before != NULL, something really bad is happening in your app. */
+   EINA_SAFETY_ON_NULL_RETURN_VAL(wd->items, NULL);
+
    if (!it->parent)
      {
         if ((flags & ELM_GENLIST_ITEM_GROUP) &&
@@ -3604,8 +3607,6 @@ elm_genlist_item_insert_after(Evas_Object                  *obj,
    /* It makes no sense to insert after in an empty list with after != NULL, something really bad is happening in your app. */
    EINA_SAFETY_ON_NULL_RETURN_VAL(wd->items, NULL);
 
-   wd->items = eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
-                                           EINA_INLIST_GET(after));
    if (!it->parent)
      {
         if ((flags & ELM_GENLIST_ITEM_GROUP) &&
@@ -3618,6 +3619,8 @@ elm_genlist_item_insert_after(Evas_Object                  *obj,
         it->parent->items = eina_list_append_relative(it->parent->items, it,
                                                       after);
      }
+   wd->items = eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
+                                           EINA_INLIST_GET(after));
    it->rel = after;
    it->rel->relcount++;
    it->before = EINA_FALSE;