okra pushed a commit to branch master.

http://git.enlightenment.org/apps/ephoto.git/commit/?id=2ab25bb5ba0f2bc93082db7651c059698e32d7cc

commit 2ab25bb5ba0f2bc93082db7651c059698e32d7cc
Author: Stephen okra Houston <[email protected]>
Date:   Mon Aug 15 17:21:04 2016 -0500

    Ephoto: Fix some warnings and potential crashes.  Improve safety checking.
---
 src/bin/ephoto.h                   |   1 +
 src/bin/ephoto_directory_browser.c |   3 +-
 src/bin/ephoto_file.c              |  12 ++--
 src/bin/ephoto_main.c              |  39 ++++++++++-
 src/bin/ephoto_single_browser.c    |  29 +++------
 src/bin/ephoto_thumb_browser.c     | 128 +++++++++++++++++++++++--------------
 6 files changed, 138 insertions(+), 74 deletions(-)

diff --git a/src/bin/ephoto.h b/src/bin/ephoto.h
index f9aff91..590bfba 100644
--- a/src/bin/ephoto.h
+++ b/src/bin/ephoto.h
@@ -301,6 +301,7 @@ struct _Ephoto
    Ephoto_State state, prev_state;
 
    Ephoto_Config *config;
+   Ephoto_Sort sort;
 };
 
 struct _Ephoto_Entry
diff --git a/src/bin/ephoto_directory_browser.c 
b/src/bin/ephoto_directory_browser.c
index 8605ff3..2a1e050 100644
--- a/src/bin/ephoto_directory_browser.c
+++ b/src/bin/ephoto_directory_browser.c
@@ -708,7 +708,8 @@ _ephoto_directory_view_add(Ephoto_Directory_Browser *db)
 static void
 _todo_items_free(Ephoto_Directory_Browser *db)
 {
-   eina_list_free(db->todo_items);
+   if (eina_list_count(db->todo_items))
+     eina_list_free(db->todo_items);
    db->todo_items = NULL;
 }
 
diff --git a/src/bin/ephoto_file.c b/src/bin/ephoto_file.c
index 7160edf..bb5d12a 100644
--- a/src/bin/ephoto_file.c
+++ b/src/bin/ephoto_file.c
@@ -655,7 +655,8 @@ _move_files(Ephoto *ephoto, Eina_List *files,
    evas_object_show(popup);
 
    ephoto->file_pos = eina_list_clone(files);
-   eina_list_free(files);
+   if (eina_list_count(files))
+     eina_list_free(files);
    ephoto->file_thread = ecore_thread_run(_move_thread_cb,
        _thread_end_cb, _thread_end_cb, popup);
 }
@@ -727,7 +728,8 @@ _copy_files(Ephoto *ephoto, Eina_List *files,
    evas_object_show(popup);
 
    ephoto->file_pos = eina_list_clone(files);
-   eina_list_free(files);
+   if (eina_list_count(files))
+     eina_list_free(files);
    ephoto->file_thread = ecore_thread_run(_copy_thread_cb,
        _thread_end_cb, NULL, popup);
 }
@@ -813,7 +815,8 @@ _delete_files(Ephoto *ephoto, Eina_List *files)
    evas_object_show(popup);
 
    ephoto->file_pos = eina_list_clone(files);
-   eina_list_free(files);
+   if (eina_list_count(files))
+     eina_list_free(files);
    ephoto->file_thread = ecore_thread_run(_delete_thread_cb,
        _thread_end_cb, NULL, popup);
 }
@@ -941,7 +944,8 @@ _empty_trash(Ephoto *ephoto, Eina_List *files)
    evas_object_show(popup);
 
    ephoto->file_pos = eina_list_clone(files);
-   eina_list_free(files);
+   if (eina_list_count(files))
+     eina_list_free(files);
    ephoto->file_thread = ecore_thread_run(_empty_trash_thread_cb,
        _thread_end_cb, NULL, popup);
 }
diff --git a/src/bin/ephoto_main.c b/src/bin/ephoto_main.c
index b765965..3e36348 100644
--- a/src/bin/ephoto_main.c
+++ b/src/bin/ephoto_main.c
@@ -207,7 +207,7 @@ _win_free(void *data, Evas *e EINA_UNUSED, Evas_Object *obj 
EINA_UNUSED,
 
    if (ephoto->file_thread)
      ecore_thread_cancel(ephoto->file_thread);
-   if (ephoto->file_pos)
+   if (eina_list_count(ephoto->file_pos))
       eina_list_free(ephoto->file_pos);
    if (ephoto->upload_handlers)
      EINA_LIST_FREE(ephoto->upload_handlers, handler)
@@ -419,6 +419,8 @@ ephoto_window_add(const char *path)
    ephoto->hover_blocking = EINA_FALSE;
    ephoto->folders_toggle = EINA_TRUE;
    ephoto->editor_blocking = EINA_FALSE;
+   ephoto->entries = NULL;
+   ephoto->sort = EPHOTO_SORT_ALPHABETICAL_ASCENDING;
    ephoto->win = elm_win_util_standard_add("ephoto", "Ephoto");
    if (!ephoto->win)
      {
@@ -695,8 +697,36 @@ int
 ephoto_entries_cmp(const void *pa, const void *pb)
 {
    const Ephoto_Entry *a = pa, *b = pb;
+   int i = 0;
+   long long moda, modb;
 
-   return strcoll(a->basename, b->basename);
+   i = strcasecmp(a->basename, b->basename);
+   moda = ecore_file_mod_time(a->path);
+   modb = ecore_file_mod_time(b->path);
+   switch (a->ephoto->sort)
+     {
+        case EPHOTO_SORT_ALPHABETICAL_ASCENDING:
+           return i;
+        case EPHOTO_SORT_ALPHABETICAL_DESCENDING:
+           return i * -1;
+        case EPHOTO_SORT_MODTIME_ASCENDING:
+           if (moda < modb)
+             return -1;
+           else if (moda > modb)
+             return 1;
+           else
+             return i;
+        case EPHOTO_SORT_MODTIME_DESCENDING:
+           if (moda < modb)
+             return 1;
+           else if (moda > modb)
+             return -1;
+           else
+             return i * -1;
+        default:
+           return i;
+     }
+   return i;
 }
 
 static void
@@ -800,6 +830,7 @@ _ephoto_populate_entries(Ephoto_Dir_Data *ed)
        ephoto_entry_free(entry->ephoto, entry);
    else if (!ed->dirs_only)
      ephoto_entries_free(ed->ephoto);
+   ed->ephoto->entries = NULL;
 
    ed->ephoto->ls =
        eio_file_stat_ls(ed->ephoto->config->directory, _ephoto_populate_filter,
@@ -1185,5 +1216,7 @@ ephoto_entries_free(Ephoto *ephoto)
 {
    Ephoto_Entry *entry;
 
-   EINA_LIST_FREE(ephoto->entries, entry) ephoto_entry_free(ephoto, entry);
+   EINA_LIST_FREE(ephoto->entries, entry)
+     ephoto_entry_free(ephoto, entry);
+   ephoto->entries = NULL;
 }
diff --git a/src/bin/ephoto_single_browser.c b/src/bin/ephoto_single_browser.c
index 70f018f..70c01db 100644
--- a/src/bin/ephoto_single_browser.c
+++ b/src/bin/ephoto_single_browser.c
@@ -72,6 +72,7 @@ static void _ephoto_main_back(void *data, Evas_Object *obj 
EINA_UNUSED,
     void *event_info EINA_UNUSED);
 static void _ephoto_main_del(void *data, Evas *e EINA_UNUSED,
     Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED);
+static void _next_entry(Ephoto_Single_Browser *sb);
 
 /*Common*/
 static const char *
@@ -297,7 +298,13 @@ _monitor_cb(void *data, int type,
    if (type == EIO_MONITOR_FILE_MODIFIED)
      {
         if (!ecore_file_exists(sb->entry->path))
-          ephoto_entry_free(sb->ephoto, sb->entry);
+          {
+             if (eina_list_count(sb->entries) > 1)
+               _next_entry(sb);
+             else
+               _ephoto_main_back(sb, NULL, NULL);
+             ephoto_entry_free(sb->ephoto, sb->entry);
+          }
         else
           {
              Evas_Object *tmp;
@@ -1466,19 +1473,6 @@ _viewer_add(Evas_Object *parent, const char *path, 
Ephoto_Single_Browser *sb)
 }
 
 /*Single Browser Populating Functions*/
-static void
-_entry_free(void *data, const Ephoto_Entry *entry)
-{
-   Ephoto_Single_Browser *sb = data;
-
-   if (entry == sb->entry)
-     {
-        if (eina_list_count(sb->entries) <= 1)
-          evas_object_smart_callback_call(sb->main, "back", NULL);
-        else
-          _next_entry(sb);
-     }
-}
 
 static Eina_Bool
 _ephoto_single_populate_end(void *data, int type EINA_UNUSED,
@@ -1995,9 +1989,8 @@ _ephoto_main_del(void *data, Evas *e EINA_UNUSED, 
Evas_Object *obj EINA_UNUSED,
    Eina_File_Direct_Info *info;
    Ephoto_History *eh;
 
-   EINA_LIST_FREE(sb->handlers, handler) ecore_event_handler_del(handler);
-   if (sb->entry)
-     ephoto_entry_free_listener_del(sb->entry, _entry_free, sb);
+   EINA_LIST_FREE(sb->handlers, handler)
+     ecore_event_handler_del(handler);
    if (sb->pending_path)
      eina_stringshare_del(sb->pending_path);
    if (sb->edit_main)
@@ -2066,7 +2059,6 @@ ephoto_single_browser_entry_set(Evas_Object *obj, 
Ephoto_Entry *entry)
         dir = ecore_file_dir_get(sb->entry->path);
         if (!eina_streq(sb->ephoto->config->directory, dir))
           {
-             ephoto_entry_free_listener_del(sb->entry, _entry_free, sb);
              sb->entry = entry;
           }
         free(dir);
@@ -2074,7 +2066,6 @@ ephoto_single_browser_entry_set(Evas_Object *obj, 
Ephoto_Entry *entry)
    if (entry)
      {
         sb->entry = entry;
-        ephoto_entry_free_listener_add(entry, _entry_free, sb);
      }
    _ephoto_single_browser_recalc(sb);
    if (sb->edited_image_data)
diff --git a/src/bin/ephoto_thumb_browser.c b/src/bin/ephoto_thumb_browser.c
index 2ced4b3..780b020 100644
--- a/src/bin/ephoto_thumb_browser.c
+++ b/src/bin/ephoto_thumb_browser.c
@@ -145,7 +145,8 @@ _dnd_drag_done(void *data EINA_UNUSED, Evas_Object *obj,
        ecore_timer_del(_5s_timeout);
        _5s_timeout = NULL;
      }
-   eina_list_free(data);
+   if (eina_list_count(data))
+     eina_list_free(data);
    elm_object_cursor_unset(tb->main);
    tb->dragging = 0;
    return;
@@ -397,6 +398,7 @@ _sort_alpha_asc(void *data, Evas_Object *obj,
    Evas_Object *ic;
 
    tb->sort = EPHOTO_SORT_ALPHABETICAL_ASCENDING;
+   tb->ephoto->sort = tb->sort;
    tb->thumbs_only = 1;
    tb->dirs_only = 0;
    ic = elm_icon_add(obj);
@@ -415,6 +417,7 @@ _sort_alpha_desc(void *data, Evas_Object *obj EINA_UNUSED,
    Evas_Object *ic;
 
    tb->sort = EPHOTO_SORT_ALPHABETICAL_DESCENDING;
+   tb->ephoto->sort = tb->sort;
    tb->thumbs_only = 1;
    tb->dirs_only = 0;
    ic = elm_icon_add(obj);
@@ -433,6 +436,7 @@ _sort_mod_asc(void *data, Evas_Object *obj EINA_UNUSED,
    Evas_Object *ic;
 
    tb->sort = EPHOTO_SORT_MODTIME_ASCENDING;
+   tb->ephoto->sort = tb->sort;
    tb->thumbs_only = 1;
    tb->dirs_only = 0;
    ic = elm_icon_add(obj);
@@ -451,6 +455,7 @@ _sort_mod_desc(void *data, Evas_Object *obj EINA_UNUSED,
    Evas_Object *ic;
 
    tb->sort = EPHOTO_SORT_MODTIME_DESCENDING;
+   tb->ephoto->sort = tb->sort;
    tb->thumbs_only = 1;
    tb->dirs_only = 0;
    ic = elm_icon_add(obj);
@@ -471,6 +476,8 @@ _similarity_items_process(void *data)
    if ((tb->animator.processed == tb->animator.count))
      {
         Evas_Object *popup = evas_object_data_get(tb->grid, "popup");
+        Eina_List *similar = NULL;
+        Elm_Object_Item *it;
 
         if (tb->animator.count == 0)
           return EINA_TRUE;
@@ -480,7 +487,31 @@ _similarity_items_process(void *data)
           {
              evas_object_del(popup);
              evas_object_data_del(popup, "popup");
+          } 
+        it = elm_gengrid_first_item_get(tb->grid);
+        while(it)
+          {
+             Ephoto_Entry *e = elm_object_item_data_get(it);
+             similar = eina_list_append(similar, e);
+             it = elm_gengrid_item_next_get(it);
+          }
+        if (tb->searching)
+          {
+             if (eina_list_count(tb->searchentries))
+               eina_list_free(tb->searchentries);
+             tb->searchentries = eina_list_clone(similar);
+          }
+        else
+          {
+             if (eina_list_count(tb->entries))
+               eina_list_free(tb->entries);
+             if (eina_list_count(tb->ephoto->entries))
+               eina_list_free(tb->ephoto->entries);
+             tb->entries = eina_list_clone(similar);
+             tb->ephoto->entries = eina_list_clone(similar);
           }
+        if (eina_list_count(similar))
+          eina_list_free(similar);
         return EINA_FALSE;
      }
    tb->animator.todo_items = NULL;
@@ -520,8 +551,8 @@ _sort_similarity(void *data, Evas_Object *obj EINA_UNUSED,
    tb->sort = EPHOTO_SORT_SIMILARITY;
    tb->thumbs_only = 1;
    tb->dirs_only = 0;
-   ic = elm_icon_add(obj);
 
+   ic = elm_icon_add(obj);
    elm_icon_standard_set(ic, "view-sort-ascending");
    elm_object_part_content_set(obj, "icon", ic);
    evas_object_show(ic);
@@ -603,7 +634,7 @@ _view_single(void *data, Evas_Object *obj EINA_UNUSED,
        eina_list_clone(elm_gengrid_selected_items_get(tb->grid));
    if (eina_list_count(selected) <= 1 && tb->searchentries)
      {
-        if (tb->ephoto->selentries)
+        if (eina_list_count(tb->ephoto->selentries))
           eina_list_free(tb->ephoto->selentries);
         tb->ephoto->selentries = NULL;
         tb->ephoto->searchentries =
@@ -620,9 +651,9 @@ _view_single(void *data, Evas_Object *obj EINA_UNUSED,
      }
    else
      {
-        if (tb->ephoto->selentries)
+        if (eina_list_count(tb->ephoto->selentries))
           eina_list_free(tb->ephoto->selentries);
-        if (tb->ephoto->searchentries)
+        if (eina_list_count(tb->ephoto->searchentries))
           eina_list_free(tb->ephoto->searchentries);
         tb->ephoto->selentries = NULL;
         tb->ephoto->searchentries = NULL;
@@ -692,7 +723,8 @@ _grid_menu_cut_cb(void *data, Evas_Object *obj EINA_UNUSED,
         file = elm_object_item_data_get(item);
         tb->cut_items = eina_list_append(tb->cut_items, strdup(file->path));
      }
-   eina_list_free(selection);
+   if (eina_list_count(selection))
+     eina_list_free(selection);
 }
 
 static void
@@ -709,12 +741,12 @@ _grid_menu_copy_cb(void *data, Evas_Object *obj 
EINA_UNUSED,
    if (eina_list_count(selection) <= 0)
      return;
 
-   if (tb->cut_items)
+   if (eina_list_count(tb->cut_items))
      {
        eina_list_free(tb->cut_items);
        tb->cut_items = NULL;
      }
-   if (tb->copy_items)
+   if (eina_list_count(tb->copy_items))
      {
        eina_list_free(tb->copy_items);
        tb->copy_items = NULL;
@@ -724,7 +756,8 @@ _grid_menu_copy_cb(void *data, Evas_Object *obj EINA_UNUSED,
         file = elm_object_item_data_get(item);
         tb->copy_items = eina_list_append(tb->copy_items, strdup(file->path));
      }
-   eina_list_free(selection);
+   if (eina_list_count(selection))
+     eina_list_free(selection);
 }
 
 static void
@@ -733,14 +766,14 @@ _grid_menu_paste_cb(void *data, Evas_Object *obj 
EINA_UNUSED,
 {
    Ephoto_Thumb_Browser *tb = data;
 
-   if (eina_list_count(tb->cut_items) > 0)
+   if (eina_list_count(tb->cut_items))
      {
         ephoto_file_paste(tb->ephoto, eina_list_clone(tb->cut_items), 
EINA_FALSE,
             tb->ephoto->config->directory);
         eina_list_free(tb->cut_items);
         tb->cut_items = NULL;
      }
-   else if (eina_list_count(tb->copy_items) > 0)
+   else if (eina_list_count(tb->copy_items))
      {
         ephoto_file_paste(tb->ephoto, eina_list_clone(tb->copy_items), 
EINA_TRUE,
             tb->ephoto->config->directory);
@@ -783,7 +816,8 @@ _grid_menu_delete_cb(void *data, Evas_Object *obj 
EINA_UNUSED,
           paths = eina_list_append(paths, strdup(file->path));
      }
    ephoto_file_delete(tb->ephoto, paths, EINA_FILE_REG);
-   eina_list_free(selection);
+   if (eina_list_count(selection))
+     eina_list_free(selection);
 }
 
 static void
@@ -859,16 +893,14 @@ _grid_mouse_up_cb(void *data, Evas *e EINA_UNUSED,
      }
    if (clear_selection)
      {
-        Eina_List *sel = eina_list_clone(selected);
-        Eina_List *node;
+        Eina_List *sel = eina_list_clone(selected); 
         Elm_Object_Item *it;
         if (eina_list_count(sel) > 0)
           {
-             EINA_LIST_FOREACH(sel, node, it)
+             EINA_LIST_FREE(sel, it)
                {
                   elm_gengrid_item_selected_set(it, EINA_FALSE);
                }
-             eina_list_free(sel);
           }
      }
    if (info->button != 3)
@@ -993,7 +1025,7 @@ _ephoto_thumb_activated(void *data, Evas_Object *obj 
EINA_UNUSED,
        eina_list_clone(elm_gengrid_selected_items_get(tb->grid));
    if (eina_list_count(selected) <= 1 && tb->searchentries)
      {
-        if (tb->ephoto->selentries)
+        if (eina_list_count(tb->ephoto->selentries))
           eina_list_free(tb->ephoto->selentries);
         tb->ephoto->selentries = NULL;
         tb->ephoto->searchentries = eina_list_clone(tb->searchentries);
@@ -1009,15 +1041,15 @@ _ephoto_thumb_activated(void *data, Evas_Object *obj 
EINA_UNUSED,
      }
    else
      {
-        if (tb->ephoto->selentries)
+        if (eina_list_count(tb->ephoto->selentries))
           eina_list_free(tb->ephoto->selentries);
-        if (tb->ephoto->searchentries)
+        if (eina_list_count(tb->ephoto->searchentries))
           eina_list_free(tb->ephoto->searchentries);
         tb->ephoto->selentries = NULL;
         tb->ephoto->searchentries = NULL;
      }
    evas_object_smart_callback_call(tb->main, "view", e);
-   if (selected)
+   if (eina_list_count(selected))
      eina_list_free(selected);
 }
 
@@ -1118,7 +1150,7 @@ _ephoto_thumb_search_go(void *data, Evas_Object *obj 
EINA_UNUSED,
 
    if (tb->original_grid)
      {
-        elm_gengrid_clear(tb->grid);
+        ephoto_thumb_browser_clear(tb->ephoto);
         elm_box_unpack(tb->gridbox, tb->grid);
         evas_object_del(tb->grid);
         tb->grid = tb->original_grid;
@@ -1127,11 +1159,10 @@ _ephoto_thumb_search_go(void *data, Evas_Object *obj 
EINA_UNUSED,
         next = elm_gengrid_first_item_get(tb->grid);
      }
    snprintf(pattern, PATH_MAX, "*%s*", search_text);
-   EINA_LIST_FOREACH(sel, l, o)
+   EINA_LIST_FREE(sel, o)
      {
         elm_gengrid_item_selected_set(o, EINA_FALSE);
      }
-   eina_list_free(sel);
    found = elm_gengrid_search_by_text_item_get(tb->grid, next, NULL, pattern,
        ELM_GLOB_MATCH_NOCASE);
    while (found)
@@ -1168,8 +1199,8 @@ _ephoto_thumb_search_go(void *data, Evas_Object *obj 
EINA_UNUSED,
    evas_object_show(tb->grid);
 
    elm_table_pack(tb->table, tb->gridbox, 0, 0, 5, 1);
-   if (tb->searchentries)
-      eina_list_free(tb->searchentries);
+   if (eina_list_count(tb->searchentries))
+     eina_list_free(tb->searchentries);
    tb->searchentries = NULL;
    if (results)
      {
@@ -1217,7 +1248,8 @@ _ephoto_thumb_search_go(void *data, Evas_Object *obj 
EINA_UNUSED,
           }
         tb->entries = tb->searchentries;
         ephoto_thumb_browser_update_info_label(tb->ephoto);
-        eina_list_free(results);
+        if (eina_list_count(results))
+          eina_list_free(results);
      }
    else
      {
@@ -1240,15 +1272,15 @@ _ephoto_thumb_search_cancel(void *data, Evas_Object 
*obj EINA_UNUSED,
    Ephoto_Thumb_Browser *tb = evas_object_data_get(search, "thumb_browser");
 
    tb->entries = tb->ephoto->entries;
-   if (tb->ephoto->searchentries)
+   if (eina_list_count(tb->ephoto->searchentries))
       eina_list_free(tb->ephoto->searchentries);
-   if (tb->searchentries)
+   if (eina_list_count(tb->searchentries))
       eina_list_free(tb->searchentries);
    tb->ephoto->searchentries = NULL;
    tb->searchentries = NULL;
    if (tb->original_grid)
      {
-        elm_gengrid_clear(tb->grid);
+        ephoto_thumb_browser_clear(tb->ephoto);
         elm_box_unpack(tb->gridbox, tb->grid);
         evas_object_del(tb->grid);
         tb->grid = tb->original_grid;
@@ -1382,7 +1414,8 @@ _ephoto_thumb_view_add(Ephoto_Thumb_Browser *tb)
 static void
 _todo_items_free(Ephoto_Thumb_Browser *tb)
 {
-   eina_list_free(tb->todo_items);
+   if (eina_list_count(tb->todo_items))
+     eina_list_free(tb->todo_items);
    tb->todo_items = NULL;
 }
 
@@ -1472,12 +1505,12 @@ _ephoto_thumb_populate_start(void *data, int type 
EINA_UNUSED,
    elm_object_item_disabled_set(tb->similarity, EINA_TRUE);
    tb->animator.processed = 0;
    tb->animator.count = 0;
-   if (tb->ephoto->selentries)
+   if (eina_list_count(tb->ephoto->selentries))
      eina_list_free(tb->ephoto->selentries);
    if (tb->searching)
      _ephoto_thumb_search_cancel(tb->search, NULL, NULL);
    _todo_items_free(tb);
-   elm_gengrid_clear(tb->grid);
+   ephoto_thumb_browser_clear(tb->ephoto);
    tb->totimages = 0;
    tb->totsize = 0;
 
@@ -1598,7 +1631,7 @@ ephoto_thumb_browser_slideshow(Evas_Object *obj)
        eina_list_clone(elm_gengrid_selected_items_get(tb->grid));
    if (eina_list_count(selected) <= 1  && tb->searchentries)
      {
-        if (tb->ephoto->selentries)
+        if (eina_list_count(tb->ephoto->selentries))
           eina_list_free(tb->ephoto->selentries);
         tb->ephoto->selentries = NULL;
         tb->ephoto->searchentries = eina_list_clone(tb->searchentries);
@@ -1613,15 +1646,15 @@ ephoto_thumb_browser_slideshow(Evas_Object *obj)
      }
    else
      {
-        if (tb->ephoto->selentries)
+        if (eina_list_count(tb->ephoto->selentries))
           eina_list_free(tb->ephoto->selentries);
-        if (tb->ephoto->searchentries)
+        if (eina_list_count(tb->ephoto->searchentries))
           eina_list_free(tb->ephoto->searchentries);
         tb->ephoto->selentries = NULL;
         tb->ephoto->searchentries = NULL;
      }
    evas_object_smart_callback_call(tb->main, "slideshow", entry);
-   if (selected)
+   if (eina_list_count(selected))
      eina_list_free(selected);
 }
 
@@ -1743,7 +1776,7 @@ _ephoto_main_key_down(void *data, Evas *e EINA_UNUSED, 
Evas_Object *obj EINA_UNU
           entry = eina_list_nth(tb->entries, 0);
         if (eina_list_count(selected) <= 1 && tb->searchentries)
           {
-             if (tb->ephoto->selentries)
+             if (eina_list_count(tb->ephoto->selentries))
                eina_list_free(tb->ephoto->selentries);
              tb->ephoto->selentries = NULL;
              tb->ephoto->searchentries = eina_list_clone(tb->searchentries);
@@ -1759,9 +1792,9 @@ _ephoto_main_key_down(void *data, Evas *e EINA_UNUSED, 
Evas_Object *obj EINA_UNU
           }
         else
           {
-             if (tb->ephoto->selentries)
+             if (eina_list_count(tb->ephoto->selentries))
                eina_list_free(tb->ephoto->selentries);
-             if (tb->ephoto->searchentries)
+             if (eina_list_count(tb->ephoto->searchentries))
                eina_list_free(tb->ephoto->searchentries);
              tb->ephoto->selentries = NULL;
              tb->ephoto->searchentries = NULL;
@@ -1804,7 +1837,7 @@ _ephoto_main_key_down(void *data, Evas *e EINA_UNUSED, 
Evas_Object *obj EINA_UNU
      {
         _ephoto_thumb_search_go(tb->search, NULL, NULL);
      }
-   if (selected)
+   if (eina_list_count(selected))
      eina_list_free(selected);
 }
 
@@ -1846,15 +1879,15 @@ _ephoto_main_del(void *data, Evas *e EINA_UNUSED, 
Evas_Object *obj EINA_UNUSED,
        eio_file_cancel(tb->ls);
        return;
      }
-   if (tb->cut_items)
+   if (eina_list_count(tb->cut_items))
       eina_list_free(tb->cut_items);
-   else if (tb->copy_items)
+   else if (eina_list_count(tb->copy_items))
       eina_list_free(tb->copy_items);
-   if (tb->ephoto->selentries)
+   if (eina_list_count(tb->ephoto->selentries))
       eina_list_free(tb->ephoto->selentries);
-   if (tb->ephoto->searchentries)
+   if (eina_list_count(tb->ephoto->searchentries))
       eina_list_free(tb->ephoto->searchentries);
-   if (tb->searchentries)
+   if (eina_list_count(tb->searchentries))
       eina_list_free(tb->searchentries);
    free(tb);
 }
@@ -1895,13 +1928,13 @@ ephoto_thumb_browser_paste(Ephoto *ephoto, 
Elm_Object_Item *item)
    else
      path = tb->ephoto->config->directory;
 
-   if (eina_list_count(tb->cut_items) > 0)
+   if (eina_list_count(tb->cut_items))
      {
         ephoto_file_paste(tb->ephoto, eina_list_clone(tb->cut_items), 
EINA_FALSE, path);
         eina_list_free(tb->cut_items);
         tb->cut_items = NULL;
      }
-   else if (eina_list_count(tb->copy_items) > 0)
+   else if (eina_list_count(tb->copy_items))
      {
         ephoto_file_paste(tb->ephoto, eina_list_clone(tb->copy_items), 
EINA_TRUE, path);
         eina_list_free(tb->copy_items);
@@ -2109,6 +2142,7 @@ ephoto_thumb_browser_add(Ephoto *ephoto, Evas_Object 
*parent)
    tb->cut_items = NULL;
    tb->copy_items = NULL;
    tb->last_sel = NULL;
+   tb->entries = NULL;
    tb->sort = EPHOTO_SORT_ALPHABETICAL_ASCENDING;
    tb->main = box;
 

-- 


Reply via email to