X-Git-Url: http://geeqie.org/cgi-bin/gitweb.cgi?p=geeqie.git;a=blobdiff_plain;f=src%2Fcollect-io.c;h=bb9967d424ba5602a3e7753147e8cb13660ce6ab;hp=c5ecabe31302d463b9585d5f45afe8a32dcf4a16;hb=c4114f7d7b6baa193ba4fbeb8693becfcd256943;hpb=445675df9548d5b7b765a07c7bfe96faa3e4ab6a diff --git a/src/collect-io.c b/src/collect-io.c index c5ecabe3..bb9967d4 100644 --- a/src/collect-io.c +++ b/src/collect-io.c @@ -1,7 +1,7 @@ /* * Geeqie * (C) 2004 John Ellis - * Copyright (C) 2008 - 2009 The Geeqie Team + * Copyright (C) 2008 - 2012 The Geeqie Team * * Author: John Ellis * @@ -155,12 +155,12 @@ static gboolean collection_load_private(CollectionData *cd, const gchar *path, C *p = 0; if (*buf) { - gint valid; + gboolean valid; if (!flush) changed |= collect_manager_process_action(entry, &buf); - valid = (buf[0] == G_DIR_SEPARATOR && collection_add_check(cd, file_data_new_simple(buf), FALSE, TRUE)); + valid = (buf[0] == G_DIR_SEPARATOR && collection_add_check(cd, file_data_new_group(buf), FALSE, TRUE)); if (!valid) DEBUG_1("collection invalid file: %s", buf); total++; @@ -190,7 +190,7 @@ static gboolean collection_load_private(CollectionData *cd, const gchar *path, C gchar *buf = NULL; while (collect_manager_process_action(entry, &buf)) { - collection_add_check(cd, file_data_new_simple(buf), FALSE, TRUE); + collection_add_check(cd, file_data_new_group(buf), FALSE, TRUE); changed = TRUE; g_free(buf); buf = NULL; @@ -447,7 +447,7 @@ struct _CollectManagerAction static GList *collection_manager_entry_list = NULL; static GList *collection_manager_action_list = NULL; static GList *collection_manager_action_tail = NULL; -static gint collection_manager_timer_id = -1; +static guint collection_manager_timer_id = 0; /* event source id */ static CollectManagerAction *collect_manager_action_new(const gchar *oldpath, const gchar *newpath, @@ -497,8 +497,14 @@ static void collect_manager_entry_free_data(CollectManagerEntry *entry) collect_manager_action_unref(action); } g_list_free(entry->add_list); - g_hash_table_destroy(entry->oldpath_hash); - g_hash_table_destroy(entry->newpath_hash); + if (g_hash_table_size(entry->oldpath_hash) > 0) + g_hash_table_destroy(entry->oldpath_hash); + else + g_hash_table_unref(entry->oldpath_hash); + if (g_hash_table_size(entry->newpath_hash) > 0) + g_hash_table_destroy(entry->newpath_hash); + else + g_hash_table_unref(entry->newpath_hash); } static void collect_manager_entry_init_data(CollectManagerEntry *entry) @@ -673,7 +679,7 @@ static void collect_manager_refresh(void) GList *work; FileData *dir_fd; - dir_fd = file_data_new_simple(get_collections_dir()); + dir_fd = file_data_new_dir(get_collections_dir()); filelist_read(dir_fd, &list, NULL); file_data_unref(dir_fd); @@ -704,6 +710,8 @@ static void collect_manager_refresh(void) else { collect_manager_entry_free(entry); + + entry = NULL; } } } @@ -725,7 +733,7 @@ static void collect_manager_refresh(void) static void collect_manager_process_actions(gint max) { if (collection_manager_action_list) DEBUG_1("collection manager processing actions"); - + while (collection_manager_action_list != NULL && max > 0) { CollectManagerAction *action; @@ -784,12 +792,11 @@ static void collect_manager_process_actions(gint max) static gboolean collect_manager_process_entry(CollectManagerEntry *entry) { CollectionData *cd; - gboolean success; if (entry->empty) return FALSE; cd = collection_new(entry->path); - success = collection_load_private(cd, entry->path, COLLECTION_LOAD_NONE); + (void) collection_load_private(cd, entry->path, COLLECTION_LOAD_NONE); collection_unref(cd); @@ -833,18 +840,18 @@ static gboolean collect_manager_timer_cb(gpointer data) g_idle_add_full(G_PRIORITY_LOW, collect_manager_process_cb, NULL, NULL); - collection_manager_timer_id = -1; + collection_manager_timer_id = 0; return FALSE; } static void collect_manager_timer_push(gint stop) { - if (collection_manager_timer_id != -1) + if (collection_manager_timer_id) { if (!stop) return; g_source_remove(collection_manager_timer_id); - collection_manager_timer_id = -1; + collection_manager_timer_id = 0; } if (!stop) @@ -934,8 +941,9 @@ void collect_manager_flush(void) void collect_manager_notify_cb(FileData *fd, NotifyType type, gpointer data) { - if (type != NOTIFY_TYPE_CHANGE || !fd->change) return; - + if (!(type & NOTIFY_CHANGE) || !fd->change) return; + + DEBUG_1("Notify collect_manager: %s %04x", fd->path, type); switch (fd->change->type) { case FILEDATA_CHANGE_MOVE: