[Bf-blender-cvs] [4815d0706fb] master: Fix T103385: Asset Browser Thumbnails take long time to load

Campbell Barton noreply at git.blender.org
Tue Jan 24 14:25:18 CET 2023


Commit: 4815d0706fb57d6e4f897dbb4e9aba9d2323cdce
Author: Campbell Barton
Date:   Wed Jan 25 00:21:13 2023 +1100
Branches: master
https://developer.blender.org/rB4815d0706fb57d6e4f897dbb4e9aba9d2323cdce

Fix T103385: Asset Browser Thumbnails take long time to load

Regression in [0] caused by a change where path joining would
replace a forward slash with a back-slash when joining paths WIN32.
Now the directory is always used as a prefix for the paths returned
by BLI_filelist_dir_contents which resolves the regression.

[0]: 9f6a045e23cf4ab132ef78eeaf070bd53d0c509f

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

M	source/blender/blenlib/intern/BLI_filelist.c

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

diff --git a/source/blender/blenlib/intern/BLI_filelist.c b/source/blender/blenlib/intern/BLI_filelist.c
index 4bcb023691a..06fb57842e0 100644
--- a/source/blender/blenlib/intern/BLI_filelist.c
+++ b/source/blender/blenlib/intern/BLI_filelist.c
@@ -114,6 +114,16 @@ static void bli_builddir(struct BuildDirCtx *dir_ctx, const char *dirname)
     const struct dirent *fname;
     bool has_current = false, has_parent = false;
 
+    char dirname_with_slash[FILE_MAXDIR + 1];
+    size_t dirname_with_slash_len = BLI_strncpy_rlen(
+        dirname_with_slash, dirname, sizeof(dirname_with_slash) - 1);
+
+    if ((dirname_with_slash_len > 0) &&
+        (BLI_path_slash_is_native_compat(dirname_with_slash_len - 1) == false)) {
+      dirname_with_slash[dirname_with_slash_len++] = SEP;
+      dirname_with_slash[dirname_with_slash_len] = '\0';
+    }
+
     while ((fname = readdir(dir)) != NULL) {
       struct dirlink *const dlink = (struct dirlink *)malloc(sizeof(struct dirlink));
       if (dlink != NULL) {
@@ -172,9 +182,14 @@ static void bli_builddir(struct BuildDirCtx *dir_ctx, const char *dirname)
       if (dir_ctx->files) {
         struct dirlink *dlink = (struct dirlink *)dirbase.first;
         struct direntry *file = &dir_ctx->files[dir_ctx->files_num];
+
+        char fullname[PATH_MAX];
+        STRNCPY(fullname, dirname_with_slash);
+        char *fullname_name_part = fullname + dirname_with_slash_len;
+        const size_t fullname_name_part_len = sizeof(fullname) - dirname_with_slash_len;
+
         while (dlink) {
-          char fullname[PATH_MAX];
-          BLI_path_join(fullname, sizeof(fullname), dirname, dlink->name);
+          BLI_strncpy(fullname_name_part, dlink->name, fullname_name_part_len);
           memset(file, 0, sizeof(struct direntry));
           file->relname = dlink->name;
           file->path = BLI_strdup(fullname);



More information about the Bf-blender-cvs mailing list