From b0a661730f022b85ef0dfd6244a7cef05357856d Mon Sep 17 00:00:00 2001 From: Fumitoshi UKAI Date: Wed, 29 Jan 2003 17:10:17 +0000 Subject: [w3m-dev 03708] Re: Don't stop loading image when moving to next page. * config.h.dist (lstat): define ifndef HAVE_LSTAT * configure (config.h) ditto * display.c (fmTerm): new loadImage (save_current_buf): only ifdef USE_BUFINFO (displayBuffer): new loadImage * etc.c (setup_child): TrapSignal * file.c (loadGeneralFile): TRAP_OFF, TRAP_ON (loadHTMLstream): ditto (loadGopherDir): ditto (loadBuffer): ditto (loadImageBuffer): ditto (getNextPage): ditto (save2tmp): ditto * fm.h (TrapSignal): added (TRAP_ON): added (TRAP_OFF): added * form.c (HAVE_LSTAT): deleted * frame.c (createFrameFile): TRAP_OFF, TRAP_ON * image.c (image_buffer): added (deleteImage): new loadImage (getAllImage): initialize image_buffer (loadImage): rewrite * main.c (main): new loadImage (checkDownloadList): remove ifdef HAVE_LSTAT * news.c (loadNwesgroup): TRAP_ON, TRAP_OFF * proto.h (loadImage): add buf arg * url.c (openSocket): TRAP_ON, TRAP_OFF (check_no_proxy): TRAP_ON, TRAP_OFF From: Hironori SAKAMOTO --- image.c | 124 +++++++++++++++++++++++++++++++++------------------------------- 1 file changed, 63 insertions(+), 61 deletions(-) (limited to 'image.c') diff --git a/image.c b/image.c index aa8942d..7f2847c 100644 --- a/image.c +++ b/image.c @@ -1,4 +1,4 @@ -/* $Id: image.c,v 1.28 2003/01/28 16:45:19 ukai Exp $ */ +/* $Id: image.c,v 1.30 2003/01/29 17:10:40 ukai Exp $ */ #include "fm.h" #include @@ -243,6 +243,7 @@ static Hash_sv *image_hash = NULL; static Hash_sv *image_file = NULL; static GeneralList *image_list = NULL; static ImageCache **image_cache = NULL; +static Buffer *image_buffer = NULL; void deleteImage(Buffer *buf) @@ -263,7 +264,7 @@ deleteImage(Buffer *buf) a->image->cache->index < 0) unlink(a->image->cache->file); } - loadImage(IMG_FLAG_STOP); + loadImage(NULL, IMG_FLAG_STOP); } void @@ -274,6 +275,7 @@ getAllImage(Buffer *buf) ParsedURL *current; int i; + image_buffer = buf; if (!buf) return; buf->image_loaded = TRUE; @@ -318,11 +320,11 @@ showImageProgress(Buffer *buf) } void -loadImage(int flag) +loadImage(Buffer *buf, int flag) { ImageCache *cache; struct stat st; - int wait_st, i; + int wait_st, i, draw = FALSE; if (maxLoadImage > MAX_LOAD_IMAGE) maxLoadImage = MAX_LOAD_IMAGE; @@ -334,74 +336,71 @@ loadImage(int flag) image_cache = New_N(ImageCache *, MAX_LOAD_IMAGE); bzero(image_cache, sizeof(ImageCache *) * MAX_LOAD_IMAGE); } - - if (flag == IMG_FLAG_STOP || flag == IMG_FLAG_START) { - if (flag == IMG_FLAG_STOP) - i = 0; - else - i = maxLoadImage; - for ( ; i < n_load_image; i++) { - cache = image_cache[i]; - if (!cache) - continue; - if (cache->pid) { - kill(cache->pid, SIGKILL); + for (i = 0; i < n_load_image; i++) { + cache = image_cache[i]; + if (!cache) + continue; + if (lstat(cache->touch, &st)) + continue; + if (cache->pid) { + kill(cache->pid, SIGKILL); +/* #ifdef HAVE_WAITPID - waitpid(cache->pid, &wait_st, 0); + waitpid(cache->pid, &wait_st, 0); #else - wait(&wait_st); + wait(&wait_st); #endif - cache->pid = 0; +*/ + cache->pid = 0; + } + if (!stat(cache->file, &st)) { + cache->loaded = IMG_FLAG_LOADED; + if (getImageSize(cache)) { + if (image_buffer) + image_buffer->need_reshape = TRUE; } - unlink(cache->touch); - image_cache[i] = NULL; + draw = TRUE; } - image_list = NULL; - image_file = NULL; - n_load_image = maxLoadImage; - return; + else + cache->loaded = IMG_FLAG_ERROR; + unlink(cache->touch); + image_cache[i] = NULL; } - { - int draw = FALSE; - for (i = 0; i < n_load_image; i++) { - cache = image_cache[i]; - if (!cache) - continue; -#ifdef HAVE_LSTAT - if (lstat(cache->touch, &st)) -#else - if (stat(cache->touch, &st)) -#endif - continue; - if (cache->pid) { - kill(cache->pid, SIGKILL); + for (i = (buf != image_buffer) ? 0 : maxLoadImage; i < n_load_image; i++) { + cache = image_cache[i]; + if (!cache) + continue; + if (cache->pid) { + kill(cache->pid, SIGKILL); +/* #ifdef HAVE_WAITPID - waitpid(cache->pid, &wait_st, 0); + waitpid(cache->pid, &wait_st, 0); #else - wait(&wait_st); + wait(&wait_st); #endif - cache->pid = 0; - } - if (!stat(cache->file, &st)) { - cache->loaded = IMG_FLAG_LOADED; - if (getImageSize(cache)) { - if (CurrentTab && Currentbuf) - Currentbuf->need_reshape = TRUE; - } - draw = TRUE; - } - else - cache->loaded = IMG_FLAG_ERROR; - unlink(cache->touch); - image_cache[i] = NULL; - } - if (draw && CurrentTab && Currentbuf) { - drawImage(); - showImageProgress(Currentbuf); +*/ + cache->pid = 0; } + unlink(cache->touch); + image_cache[i] = NULL; } + if (flag == IMG_FLAG_STOP) { + image_list = NULL; + image_file = NULL; + n_load_image = maxLoadImage; + image_buffer = NULL; + return; + } + + if (draw && image_buffer) { + drawImage(); + showImageProgress(image_buffer); + } + + image_buffer = buf; + if (!image_list) return; for (i = 0; i < n_load_image; i++) { @@ -416,8 +415,8 @@ loadImage(int flag) } image_list = NULL; image_file = NULL; - if (CurrentTab && Currentbuf) - displayBuffer(Currentbuf, B_NORMAL); + if (image_buffer) + displayBuffer(image_buffer, B_NORMAL); return; } if (cache->loaded == IMG_FLAG_UNLOADED) @@ -428,7 +427,10 @@ loadImage(int flag) flush_tty(); if ((cache->pid = fork()) == 0) { Buffer *b; +/* setup_child(TRUE, 0, -1); +*/ + setup_child(FALSE, 0, -1); image_source = cache->file; b = loadGeneralFile(cache->url, cache->current, NULL, 0, NULL); if (!b || !b->real_type || strncasecmp(b->real_type, "image/", 6)) -- cgit v1.2.3