Edje: edje edit - ability to remove last item in BOX/TABLE
authorVitalii Vorobiov <vi.vorobiov@samsung.com>
Thu, 19 Mar 2015 13:19:55 +0000 (15:19 +0200)
committerVitalii Vorobiov <vi.vorobiov@samsung.com>
Thu, 19 Mar 2015 13:19:55 +0000 (15:19 +0200)
Removing last item in BOX/TABLE part is actually successful
but then we shouldn't realloc an array of items for 0 items.
That's ridiculous
(and because of that function removes EINA_FALSE,
so user could think that it's unable to remove last item).

So simply array can be set into NULL.

@fix

src/lib/edje/edje_edit.c

index 497be60..216d85c 100644 (file)
@@ -4556,13 +4556,18 @@ edje_edit_part_item_del(Evas_Object *obj, const char *part, const char* name)
            i++;
         }
 
-      tmp = realloc(ep->items, sizeof(Edje_Pack_Element *) * ep->items_count);
-      if (!tmp)
+      if (ep->items_count != 0)
         {
-           free(item);
-           return EINA_FALSE;
+           tmp = realloc(ep->items, sizeof(Edje_Pack_Element *) * ep->items_count);
+           if (!tmp)
+             {
+                free(item);
+                return EINA_FALSE;
+             }
+           ep->items = tmp;
         }
-      ep->items = tmp;
+      else
+        ep->items = NULL;
    }
 
    GET_EED_OR_RETURN(EINA_FALSE);