Krolyxon
Commit 1d7849e

Branches

Refs →

nsxiv1d7849e

Added force parameter to tns_load() to disregard cache

Author
Bert
Date
2011-08-19 13:26 +0200
Parent
421f012
Commit
1d7849efc1fe85d20b8aa4916e75cb3eb658dba9

+14 −12

4 files changed

  1. M events.c +4 −4
  2. M main.c +1 −1
  3. M thumbs.c +8 −6
  4. M thumbs.h +1 −1
M events.c View
@@ -163,7 +163,7 @@ void run() {
163163 gettimeofday(&t0, 0);
164164
165165 while (tns.cnt < filecnt && !XPending(win.env.dpy)) {
166− if (tns_load(&tns, tns.cnt, &files[tns.cnt], 0))
166+ if (tns_load(&tns, tns.cnt, &files[tns.cnt], False, False))
167167 tns.cnt++;
168168 else
169169 remove_file(tns.cnt, 0);
@@ -279,7 +279,7 @@ int it_toggle_fullscreen(arg_t a) {
279279 int it_reload_image(arg_t a) {
280280 if (mode == MODE_IMAGE) {
281281 load_image(fileidx);
282− } else if (!tns_load(&tns, tns.sel, &files[tns.sel], 0)) {
282+ } else if (!tns_load(&tns, tns.sel, &files[tns.sel], True, False)) {
283283 remove_file(tns.sel, 0);
284284 tns.dirty = 1;
285285 if (tns.sel >= tns.cnt)
@@ -578,11 +578,11 @@ int it_shell_cmd(arg_t a) {
578578
579579 if (mode == MODE_IMAGE) {
580580 if (fileidx < tns.cnt)
581− tns_load(&tns, fileidx, &files[fileidx], 1);
581+ tns_load(&tns, fileidx, &files[fileidx], False, True);
582582 img_close(&img, 1);
583583 load_image(fileidx);
584584 } else {
585− if (!tns_load(&tns, tns.sel, &files[tns.sel], 0)) {
585+ if (!tns_load(&tns, tns.sel, &files[tns.sel], True, False)) {
586586 remove_file(tns.sel, 0);
587587 tns.dirty = 1;
588588 if (tns.sel >= tns.cnt)
M main.c View
@@ -240,7 +240,7 @@ int main(int argc, char **argv) {
240240 if (options->thumbnails) {
241241 mode = MODE_THUMB;
242242 tns_init(&tns, filecnt);
243− while (!tns_load(&tns, 0, &files[0], 0))
243+ while (!tns_load(&tns, 0, &files[0], False, False))
244244 remove_file(0, 0);
245245 tns.cnt = 1;
246246 } else {
M thumbs.c View
@@ -212,9 +212,11 @@ void tns_free(tns_t *tns) {
212212 }
213213 }
214214
215−int tns_load(tns_t *tns, int n, const fileinfo_t *file, unsigned char silent) {
215+int tns_load(tns_t *tns, int n, const fileinfo_t *file,
216+ Bool force, Bool silent)
217+{
216218 int w, h;
217− int use_cache, cached = 0;
219+ int use_cache, cache_hit = 0;
218220 float z, zw, zh;
219221 thumb_t *t;
220222 Imlib_Image *im;
@@ -234,11 +236,11 @@ int tns_load(tns_t *tns, int n, const fileinfo_t *file, unsigned char silent) {
234236 }
235237
236238 if ((use_cache = tns_cache_enabled())) {
237− if ((im = tns_cache_load(file->path)))
238− cached = 1;
239+ if (!force && (im = tns_cache_load(file->path)))
240+ cache_hit = 1;
239241 }
240242
241− if (!cached &&
243+ if (!cache_hit &&
242244 (access(file->path, R_OK) || !(im = imlib_load_image(file->path))))
243245 {
244246 if (!silent)
@@ -262,7 +264,7 @@ int tns_load(tns_t *tns, int n, const fileinfo_t *file, unsigned char silent) {
262264
263265 imlib_free_image_and_decache();
264266
265− if (use_cache && !cached)
267+ if (use_cache && !cache_hit)
266268 tns_cache_write(t, False);
267269
268270 tns->dirty = 1;
M thumbs.h View
@@ -51,7 +51,7 @@ void tns_clean_cache(tns_t*);
5151 void tns_init(tns_t*, int);
5252 void tns_free(tns_t*);
5353
54−int tns_load(tns_t*, int, const fileinfo_t*, unsigned char);
54+int tns_load(tns_t*, int, const fileinfo_t*, Bool, Bool);
5555
5656 void tns_render(tns_t*, win_t*);
5757 void tns_highlight(tns_t*, win_t*, int, Bool);