Commit: 425e8119dec27d552bc1ffebeb88e2b2acd4722c
Author: Bastien Montagne
Date:   Wed Dec 31 20:45:39 2014 +0100
Branches: asset-experiments
https://developer.blender.org/rB425e8119dec27d552bc1ffebeb88e2b2acd4722c

SpaceFile: Tweak thumbnail to avoid restarting the job needlessly.

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

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/editors/space_file/filelist.c 
b/source/blender/editors/space_file/filelist.c
index 3609541..4177901 100644
--- a/source/blender/editors/space_file/filelist.c
+++ b/source/blender/editors/space_file/filelist.c
@@ -227,6 +227,8 @@ typedef struct FileList {
        int *fidx;  /* Also used to detect when we need to filter! */
        int numfiltered;
 
+       bool need_thumbnails;
+
        struct BlendHandle *libfiledata;
 
        void (*readf)(struct FileList *);
@@ -995,6 +997,7 @@ void filelist_readdir(struct FileList *filelist)
        filelist->readf(filelist);
 
        filelist->need_sorting = true;
+       filelist->need_thumbnails = true;
        filelist_filter_clear(filelist);
 }
 
@@ -1334,6 +1337,11 @@ typedef struct ThumbnailJob {
        ReportList reports;
 } ThumbnailJob;
 
+bool filelist_need_thumbnails(FileList *filelist)
+{
+       return filelist->need_thumbnails;
+}
+
 static void thumbnail_joblist_free(ThumbnailJob *tj)
 {
        FileImage *limg = tj->loadimages.first;
@@ -1397,6 +1405,15 @@ static void thumbnails_update(void *tjv)
        }
 }
 
+static void thumbnails_endjob(void *tjv)
+{
+       ThumbnailJob *tj = tjv;
+
+       if (!*tj->stop) {
+               tj->filelist->need_thumbnails = false;
+       }
+}
+
 static void thumbnails_free(void *tjv)
 {
        ThumbnailJob *tj = tjv;
@@ -1433,7 +1450,7 @@ void thumbnails_start(FileList *filelist, const bContext 
*C)
                             0, WM_JOB_TYPE_FILESEL_THUMBNAIL);
        WM_jobs_customdata_set(wm_job, tj, thumbnails_free);
        WM_jobs_timer(wm_job, 0.5, NC_WINDOW, NC_WINDOW);
-       WM_jobs_callbacks(wm_job, thumbnails_startjob, NULL, thumbnails_update, 
NULL);
+       WM_jobs_callbacks(wm_job, thumbnails_startjob, NULL, thumbnails_update, 
thumbnails_endjob);
 
        /* start the job */
        WM_jobs_start(CTX_wm_manager(C), wm_job);
@@ -1441,7 +1458,7 @@ void thumbnails_start(FileList *filelist, const bContext 
*C)
 
 void thumbnails_stop(wmWindowManager *wm, FileList *filelist)
 {
-       WM_jobs_kill(wm, filelist, NULL);
+       WM_jobs_kill_type(wm, filelist, WM_JOB_TYPE_FILESEL_THUMBNAIL);
 }
 
 int thumbnails_running(wmWindowManager *wm, FileList *filelist)
diff --git a/source/blender/editors/space_file/filelist.h 
b/source/blender/editors/space_file/filelist.h
index 2bb6f6a..f2b03c0 100644
--- a/source/blender/editors/space_file/filelist.h
+++ b/source/blender/editors/space_file/filelist.h
@@ -105,6 +105,7 @@ struct BlendHandle *filelist_lib(struct FileList *filelist);
 bool                filelist_islibrary(struct FileList *filelist, char *dir, 
char *group);
 void                filelist_freelib(struct FileList *filelist);
 
+bool                filelist_need_thumbnails(struct FileList *filelist);
 void                thumbnails_start(struct FileList *filelist, const struct 
bContext *C);
 void                thumbnails_stop(struct wmWindowManager *wm, struct 
FileList *filelist);
 int                 thumbnails_running(struct wmWindowManager *wm, struct 
FileList *filelist);
diff --git a/source/blender/editors/space_file/space_file.c 
b/source/blender/editors/space_file/space_file.c
index a4a216f..3f21e56 100644
--- a/source/blender/editors/space_file/space_file.c
+++ b/source/blender/editors/space_file/space_file.c
@@ -218,7 +218,7 @@ static void file_refresh(const bContext *C, ScrArea 
*UNUSED(sa))
                filelist_sort(sfile->files);
        }
 
-       if ((params->display == FILE_IMGDISPLAY)) {
+       if ((params->display == FILE_IMGDISPLAY) && 
filelist_need_thumbnails(sfile->files)) {
                if (!thumbnails_running(wm, sfile->files)) {
                        thumbnails_start(sfile->files, C);
                }

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

Reply via email to