fix wallpaper crash on adding path then cancel

this fixes T711 :)
This commit is contained in:
Carsten Haitzler 2014-01-01 13:24:28 +09:00
parent 4bfa81d2d6
commit fd30817bb1
1 changed files with 18 additions and 17 deletions

View File

@ -57,7 +57,6 @@ _grid_content_get(void *data, Evas_Object *obj, const char *part)
{ {
if (item->path) if (item->path)
{ {
int len0;
int i, ret = 0; int i, ret = 0;
for (i = 0; extn_edj[i]; i++) for (i = 0; extn_edj[i]; i++)
@ -121,6 +120,7 @@ static char *
_item_label_get(void *data, Evas_Object *obj EINA_UNUSED, const char *part EINA_UNUSED) _item_label_get(void *data, Evas_Object *obj EINA_UNUSED, const char *part EINA_UNUSED)
{ {
Wallpaper_Path_Item *item = data; Wallpaper_Path_Item *item = data;
if (!item->path) return NULL;
return strdup(item->path); return strdup(item->path);
} }
@ -140,15 +140,20 @@ _fill_path_list(Eina_List *paths, Evas_Object *list)
itc->func.del = NULL; itc->func.del = NULL;
EINA_LIST_FOREACH(paths, node, path) EINA_LIST_FOREACH(paths, node, path)
{ {
if (!path) continue;
wpi = calloc(1, sizeof(Wallpaper_Path_Item)); wpi = calloc(1, sizeof(Wallpaper_Path_Item));
if (wpi) if (wpi)
{ {
wpi->path = eina_stringshare_add(path); wpi->path = eina_stringshare_add(path);
if (wpi->path)
{
elm_genlist_item_append(list, itc, wpi, NULL, elm_genlist_item_append(list, itc, wpi, NULL,
ELM_GENLIST_ITEM_NONE, ELM_GENLIST_ITEM_NONE,
NULL, NULL); NULL, NULL);
pathlist = eina_list_append(pathlist, wpi); pathlist = eina_list_append(pathlist, wpi);
} }
else free(wpi);
}
} }
elm_gengrid_item_class_free(itc); elm_gengrid_item_class_free(itc);
evas_object_size_hint_weight_set(list, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_size_hint_weight_set(list, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
@ -173,7 +178,7 @@ _file_is_chosen(void *data, Evas_Object *obj EINA_UNUSED, void *event)
evas_object_del(list); evas_object_del(list);
EINA_LIST_FREE(pathlist, item) EINA_LIST_FREE(pathlist, item)
{ {
eina_stringshare_del(item->path); if (item->path) eina_stringshare_del(item->path);
free(item); free(item);
} }
list = elm_genlist_add(inwin); list = elm_genlist_add(inwin);
@ -202,7 +207,7 @@ _delete_path_click(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UN
evas_object_del(list); evas_object_del(list);
EINA_LIST_FREE(pathlist, item) EINA_LIST_FREE(pathlist, item)
{ {
eina_stringshare_del(item->path); if (item->path) eina_stringshare_del(item->path);
free(item); free(item);
} }
list = elm_genlist_add(inwin); list = elm_genlist_add(inwin);
@ -281,9 +286,8 @@ static Eina_List*
_rec_read_directorys(Eina_List *list, char *root_path, Evas_Object *term) _rec_read_directorys(Eina_List *list, char *root_path, Evas_Object *term)
{ {
Eina_List *childs = ecore_file_ls(root_path); Eina_List *childs = ecore_file_ls(root_path);
char *file_name; char *file_name, path[PATH_MAX];
int i, j, len0; int i, j;
char path[PATH_MAX];
Background_Item *item; Background_Item *item;
if (!childs) return list; if (!childs) return list;
@ -476,13 +480,10 @@ options_wallpaper_clear(void)
free(item); free(item);
} }
backgroundlist = NULL; backgroundlist = NULL;
if (pathlist)
{
EINA_LIST_FREE(pathlist, wpi) EINA_LIST_FREE(pathlist, wpi)
{ {
eina_stringshare_del(wpi->path); if (wpi->path) eina_stringshare_del(wpi->path);
free(wpi); free(wpi);
} }
pathlist = NULL; pathlist = NULL;
}
} }