Commit: 75d77a34756da9888b82c4316f743767e509470b
Author: Bastien Montagne
Date:   Thu Sep 8 15:23:33 2016 +0200
Branches: asset-engine
https://developer.blender.org/rB75d77a34756da9888b82c4316f743767e509470b

Allow asset engines to change current dir also from list_dir function.

Rational is, in case of online repo, it may not be practical to decide
whether a path is valid or not from check_dir() callback, which should return
immediately.

So instead, check_dir() can only check whether path **looks** good, and
delegate actual path validation to list_dir (and maybe other similar functions).

That’s what is being tested with Claude engine at least.

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

M       source/blender/blenkernel/BKE_asset_engine.h
M       source/blender/editors/space_file/filelist.c
M       source/blender/editors/space_file/filelist.h
M       source/blender/editors/space_file/space_file.c

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

diff --git a/source/blender/blenkernel/BKE_asset_engine.h 
b/source/blender/blenkernel/BKE_asset_engine.h
index 9501e12..5d2f28b 100644
--- a/source/blender/blenkernel/BKE_asset_engine.h
+++ b/source/blender/blenkernel/BKE_asset_engine.h
@@ -87,7 +87,8 @@ typedef void (*ae_kill)(struct AssetEngine *engine, const int 
job_id);
 #define AE_JOB_ID_UNSET 0
 #define AE_JOB_ID_INVALID -1
 
-/* FILEBROWSER - List everything available at given root path - only returns 
numbers of entries! */
+/* FILEBROWSER - List everything available at given root path - only returns 
numbers of entries!
+ * Note that asset engine may change root_path here too. */
 typedef int (*ae_list_dir)(struct AssetEngine *engine, const int job_id, 
struct FileDirEntryArr *entries_r);
 
 /* 'update' hook, called to prepare updating of given entries (typically after 
a file (re)load).
diff --git a/source/blender/editors/space_file/filelist.c 
b/source/blender/editors/space_file/filelist.c
index 5e52015..0b77159 100644
--- a/source/blender/editors/space_file/filelist.c
+++ b/source/blender/editors/space_file/filelist.c
@@ -2950,6 +2950,9 @@ static void filelist_readjob_main(
 typedef struct FileListReadJob {
        ThreadMutex lock;
        char main_name[FILE_MAX];
+
+       FileSelectParams *params;
+
        struct FileList *filelist;
        struct FileList *tmp_filelist;  /* XXX We may use a simpler struct 
here... just a linked list and root path? */
 
@@ -3018,6 +3021,11 @@ static void filelist_readjob_update(void *flrjv)
 
                flrj->filelist->flags |= (FL_NEED_SORTING | FL_NEED_FILTERING);
 
+               /* Asset engines are allowed to change current dir here... */
+               if (!STREQ(flrj->filelist->filelist.root, flrj->params->dir)) {
+                       BLI_strncpy(flrj->params->dir, 
flrj->filelist->filelist.root, sizeof(flrj->params->dir));
+               }
+
                if (flrj->ae_job_id == AE_JOB_ID_INVALID) {  /* Immediate 
execution. */
                        *flrj->progress = 1.0f;
                        *flrj->stop = true;
@@ -3103,7 +3111,7 @@ static void filelist_readjob_free(void *flrjv)
        MEM_freeN(flrj);
 }
 
-void filelist_readjob_start(FileList *filelist, const bContext *C)
+void filelist_readjob_start(const bContext *C, FileList *filelist, 
FileSelectParams *params)
 {
        wmJob *wm_job;
        FileListReadJob *flrj;
@@ -3111,6 +3119,7 @@ void filelist_readjob_start(FileList *filelist, const 
bContext *C)
        /* prepare job data */
        flrj = MEM_callocN(sizeof(*flrj), __func__);
        flrj->filelist = filelist;
+       flrj->params = params;
        BLI_strncpy(flrj->main_name, G.main->name, sizeof(flrj->main_name));
 
        filelist->flags &= ~(FL_FORCE_RESET | FL_IS_READY);
diff --git a/source/blender/editors/space_file/filelist.h 
b/source/blender/editors/space_file/filelist.h
index d045f70..3b08f9d 100644
--- a/source/blender/editors/space_file/filelist.h
+++ b/source/blender/editors/space_file/filelist.h
@@ -116,7 +116,7 @@ void                filelist_freelib(struct FileList 
*filelist);
 
 struct AssetEngine *filelist_assetengine_get(struct FileList *filelist);
 
-void                filelist_readjob_start(struct FileList *filelist, const 
struct bContext *C);
+void                filelist_readjob_start(const struct bContext *C, struct 
FileList *filelist, FileSelectParams *params);
 void                filelist_readjob_stop(struct wmWindowManager *wm, struct 
ScrArea *sa);
 int                 filelist_readjob_running(struct wmWindowManager *wm, 
struct ScrArea *sa);
 
diff --git a/source/blender/editors/space_file/space_file.c 
b/source/blender/editors/space_file/space_file.c
index 7e230b5..ad46d7c 100644
--- a/source/blender/editors/space_file/space_file.c
+++ b/source/blender/editors/space_file/space_file.c
@@ -259,7 +259,7 @@ static void file_refresh(const bContext *C, ScrArea *sa)
 
        if (filelist_empty(sfile->files)) {
                if (!filelist_pending(sfile->files)) {
-                       filelist_readjob_start(sfile->files, C);
+                       filelist_readjob_start(C, sfile->files, params);
                }
        }

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

Reply via email to