Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Montagne <montagne29@wanadoo.fr>2014-12-31 22:45:39 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2015-01-01 13:11:37 +0300
commit46bce66805172ff580a5cb88c5f82c2feef5a52d (patch)
treef72d776f11c2201c51c06b974575100a696ccfb6 /source/blender
parent950f2c84a3fd946d42d305cfc40b6827fc572aab (diff)
SpaceFile: Tweak thumbnail to avoid restarting the job needlessly.
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/editors/space_file/filelist.c21
-rw-r--r--source/blender/editors/space_file/filelist.h1
-rw-r--r--source/blender/editors/space_file/space_file.c2
3 files changed, 21 insertions, 3 deletions
diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c
index 36095410e69..41779018381 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 2bb6f6ae68b..f2b03c059f2 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 a4a216fb515..3f21e561546 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);
}