[Bf-blender-cvs] [d500fe6dbc9] asset-browser: Fix wrong assets displayed if repository is invalid

Julian Eisel noreply at git.blender.org
Sun Nov 22 17:35:30 CET 2020


Commit: d500fe6dbc9ca2c1f775c91c2f9b305038a647ef
Author: Julian Eisel
Date:   Sun Nov 22 17:21:58 2020 +0100
Branches: asset-browser
https://developer.blender.org/rBd500fe6dbc9ca2c1f775c91c2f9b305038a647ef

Fix wrong assets displayed if repository is invalid

If the repository did not point to a valid .blend, all .blend files in the
parent directory were read, and all their assets shown. While this may be a
cool side effect, it's not wanted by design and would break when dragging in
assets.

The followup commit will add a hint text to the Asset Browser UI if the
repository is invalid.

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

M	source/blender/editors/space_file/filelist.c

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

diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c
index cb2370b6cf6..1a4bc3b53dc 100644
--- a/source/blender/editors/space_file/filelist.c
+++ b/source/blender/editors/space_file/filelist.c
@@ -1826,11 +1826,12 @@ bool filelist_is_dir(struct FileList *filelist, const char *path)
  */
 void filelist_setdir(struct FileList *filelist, char *r_dir)
 {
+  const bool allow_invalid = filelist->asset_repository;
   BLI_assert(strlen(r_dir) < FILE_MAX_LIBEXTRA);
 
   BLI_path_normalize_dir(BKE_main_blendfile_path_from_global(), r_dir);
-  const bool is_valid_path = filelist->checkdirf(filelist, r_dir, true);
-  BLI_assert(is_valid_path);
+  const bool is_valid_path = filelist->checkdirf(filelist, r_dir, !allow_invalid);
+  BLI_assert(is_valid_path || allow_invalid);
   UNUSED_VARS_NDEBUG(is_valid_path);
 
   if (!STREQ(filelist->filelist.root, r_dir)) {
@@ -3369,6 +3370,10 @@ void filelist_readjob_start(FileList *filelist, const bContext *C)
   wmJob *wm_job;
   FileListReadJob *flrj;
 
+  if (!filelist_is_dir(filelist, filelist->filelist.root)) {
+    return;
+  }
+
   /* prepare job data */
   flrj = MEM_callocN(sizeof(*flrj), __func__);
   flrj->filelist = filelist;



More information about the Bf-blender-cvs mailing list