Commit: 55c792df8e69e57f47803010bf21b185527f374a
Author: Bastien Montagne
Date:   Fri Jan 2 17:38:25 2015 +0100
Branches: asset-experiments
https://developer.blender.org/rB55c792df8e69e57f47803010bf21b185527f374a

Add 'dup_poin' callback param to new `BLI_duplicate_filelist()` func, to allow 
handling direntry's poin if needed.

===================================================================

M       source/blender/blenlib/BLI_fileops.h
M       source/blender/blenlib/intern/storage.c
M       source/blender/editors/space_file/filelist.c

===================================================================

diff --git a/source/blender/blenlib/BLI_fileops.h 
b/source/blender/blenlib/BLI_fileops.h
index 260827f..9335bba 100644
--- a/source/blender/blenlib/BLI_fileops.h
+++ b/source/blender/blenlib/BLI_fileops.h
@@ -89,7 +89,9 @@ double BLI_dir_free_space(const char *dir);
 char  *BLI_current_working_dir(char *dir, const size_t maxlen);
 
 unsigned int BLI_dir_contents(const char *dir, struct direntry **filelist);
-void BLI_duplicate_filelist(struct direntry **dest_filelist, struct direntry 
*src_filelist, unsigned int nrentries);
+void BLI_duplicate_filelist(
+        struct direntry **dest_filelist, struct direntry *src_filelist, 
unsigned int nrentries,
+        void *(*dup_poin)(void *));
 void BLI_free_filelist(struct direntry *filelist, unsigned int nrentries);
 
 /* Files */
diff --git a/source/blender/blenlib/intern/storage.c 
b/source/blender/blenlib/intern/storage.c
index 3ed3b07..13fedbc 100644
--- a/source/blender/blenlib/intern/storage.c
+++ b/source/blender/blenlib/intern/storage.c
@@ -411,8 +411,12 @@ unsigned int BLI_dir_contents(const char *dirname,  struct 
direntry **filelist)
 
 /**
  * Deep-duplicate of an array of direntries, including the array itself.
+ *
+ * \param dup_poin If given, called for each non-NULL direntry->poin. 
Otherwise, pointer is always simply copied over.
  */
-void BLI_duplicate_filelist(struct direntry **dest_filelist, struct direntry 
*src_filelist, unsigned int nrentries)
+void BLI_duplicate_filelist(
+        struct direntry **dest_filelist, struct direntry *src_filelist, 
unsigned int nrentries,
+        void *(*dup_poin)(void *))
 {
        unsigned int i;
 
@@ -430,7 +434,9 @@ void BLI_duplicate_filelist(struct direntry 
**dest_filelist, struct direntry *sr
                if (dest->path) {
                        dest->path = MEM_dupallocN(src->path);
                }
-               /* entry->poin assumed not needing any handling here. */
+               if (dest->poin && dup_poin) {
+                       dest->poin = dup_poin(src->poin);
+               }
        }
 }
 
diff --git a/source/blender/editors/space_file/filelist.c 
b/source/blender/editors/space_file/filelist.c
index 636f84e..65f8a69 100644
--- a/source/blender/editors/space_file/filelist.c
+++ b/source/blender/editors/space_file/filelist.c
@@ -1907,8 +1907,8 @@ static void filelist_readjob_update(void *flrjv)
        if (flrj->tmp_filelist->numfiles != flrj->filelist->numfiles) {
                num_new_entries = flrj->tmp_filelist->numfiles;
                /* This way we are sure we won't share any mem with background 
job! */
-               /* Note direntry->poin is not handled here, should not matter 
though. */
-               BLI_duplicate_filelist(&new_entries, 
flrj->tmp_filelist->filelist, num_new_entries);
+               /* Note direntry->poin is not handled here, should not matter 
though currently. */
+               BLI_duplicate_filelist(&new_entries, 
flrj->tmp_filelist->filelist, num_new_entries, NULL);
        }
 
        BLI_mutex_unlock(&flrj->lock);

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to