From 262e6db70e5a541fbb09a25bde61831d5ccc273e Mon Sep 17 00:00:00 2001 From: Teruaki Kawashima Date: Wed, 19 Jan 2011 13:20:00 +0000 Subject: [PATCH] image viewer: png: do not show custom error message when there is not enough memory. get rid of use of iv->plug_buf. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29091 a1c6a512-1295-4272-9138-f99709370657 --- apps/plugins/imageviewer/png/png.c | 35 +++++++--------------- apps/plugins/imageviewer/png/png.make | 2 +- apps/plugins/imageviewer/png/png_decoder.c | 5 +++- 3 files changed, 16 insertions(+), 26 deletions(-) diff --git a/apps/plugins/imageviewer/png/png.c b/apps/plugins/imageviewer/png/png.c index 10404b7c30..1916f9c55f 100644 --- a/apps/plugins/imageviewer/png/png.c +++ b/apps/plugins/imageviewer/png/png.c @@ -194,39 +194,26 @@ static int load_image(char *filename, struct image_info *info, } if (p_decoder->error) { -#ifdef USE_PLUG_BUF - if (iv->plug_buf && (p_decoder->error == FILE_TOO_LARGE || - p_decoder->error == OUT_OF_MEMORY || - p_decoder->error == TINF_DATA_ERROR)) + if (p_decoder->error == FILE_TOO_LARGE || + p_decoder->error == OUT_OF_MEMORY) + { return PLUGIN_OUTOFMEM; -#endif + } - if (p_decoder->error >= PNG_ERROR_MIN && - p_decoder->error <= PNG_ERROR_MAX && - LodePNG_perror(p_decoder) != NULL) + if (LodePNG_perror(p_decoder) != NULL) { rb->splash(HZ, LodePNG_perror(p_decoder)); } + else if (p_decoder->error == TINF_DATA_ERROR) + { + rb->splash(HZ, "Zlib decompressor error"); + } else { - switch (p_decoder->error) { - case PLUGIN_ABORT: - break; - case OUT_OF_MEMORY: - rb->splash(HZ, "Out of Memory");break; - case FILE_TOO_LARGE: - rb->splash(HZ, "File too large");break; - case TINF_DATA_ERROR: - rb->splash(HZ, "Zlib decompressor error");break; - default: - rb->splashf(HZ, "other error : %ld", p_decoder->error);break; - } + rb->splashf(HZ, "other error : %ld", p_decoder->error); } - if (p_decoder->error == PLUGIN_ABORT) - return PLUGIN_ABORT; - else - return PLUGIN_ERROR; + return PLUGIN_ERROR; } info->x_size = p_decoder->infoPng.width; diff --git a/apps/plugins/imageviewer/png/png.make b/apps/plugins/imageviewer/png/png.make index dee89acb71..cac46ceb19 100644 --- a/apps/plugins/imageviewer/png/png.make +++ b/apps/plugins/imageviewer/png/png.make @@ -18,7 +18,7 @@ OTHER_SRC += $(PNG_SRC) ROCKS += $(PNGBUILDDIR)/png.ovl $(PNGBUILDDIR)/png.refmap: $(PNG_OBJ) -$(PNGBUILDDIR)/png.link: $(PNG_OBJ) $(PNGBUILDDIR)/png.refmap +$(PNGBUILDDIR)/png.link: $(PLUGIN_LDS) $(PNGBUILDDIR)/png.refmap $(PNGBUILDDIR)/png.ovl: $(PNG_OBJ) # Use -O3 for png plugin : it gives a bigger file but very good performances diff --git a/apps/plugins/imageviewer/png/png_decoder.c b/apps/plugins/imageviewer/png/png_decoder.c index a0ce0519de..1349d75db6 100644 --- a/apps/plugins/imageviewer/png/png_decoder.c +++ b/apps/plugins/imageviewer/png/png_decoder.c @@ -2189,5 +2189,8 @@ void LodePNG_Decoder_init(LodePNG_Decoder* decoder, const char* LodePNG_perror(LodePNG_Decoder *decoder) { - return png_error_messages[decoder->error-PNG_ERROR_MIN]; + if (decoder->error >= PNG_ERROR_MIN && decoder->error <= PNG_ERROR_MAX) + return png_error_messages[decoder->error-PNG_ERROR_MIN]; + else + return NULL; }