Merge remote-tracking branches 'merge-requests/6' and 'merge-requests/7'
[geeqie.git] / src / filedata.c
index 6adafc2..c99f3a9 100644 (file)
 
 #include <errno.h>
 
+#ifdef DEBUG_FILEDATA
+gint global_file_data_count = 0;
+#endif
+
 static GHashTable *file_data_pool = NULL;
 static GHashTable *file_data_planned_change_hash = NULL;
 
@@ -383,6 +387,10 @@ static FileData *file_data_new(const gchar *path_utf8, struct stat *st, gboolean
                }
 
        fd = g_new0(FileData, 1);
+#ifdef DEBUG_FILEDATA
+       global_file_data_count++;
+       DEBUG_2("file data count++: %d", global_file_data_count);
+#endif
 
        fd->size = st->st_size;
        fd->date = st->st_mtime;
@@ -534,6 +542,11 @@ static void file_data_free(FileData *fd)
        g_assert(fd->ref == 0);
        g_assert(!fd->locked);
 
+#ifdef DEBUG_FILEDATA
+       global_file_data_count--;
+       DEBUG_2("file data count--: %d", global_file_data_count);
+#endif
+
        metadata_cache_free(fd);
        g_hash_table_remove(file_data_pool, fd->original_path);
 
@@ -1249,8 +1262,11 @@ FileData *file_data_new_group(const gchar *path_utf8)
        filelist_read_real(dir, &files, NULL, TRUE);
 
        fd = g_hash_table_lookup(file_data_pool, path_utf8);
-       g_assert(fd);
-       file_data_ref(fd);
+       if (!fd) fd = file_data_new(path_utf8, &st, TRUE);
+       if (fd)
+               {
+               file_data_ref(fd);
+               }
 
        filelist_free(files);
        g_free(dir);