Commit 738bf712 authored by Michael Natterer's avatar Michael Natterer 😴

Issue #1634 - PNG image opens as a blank one in GIMP

Set the libpng error_fn to NULL *after* png_read_end() not before.
png_read_end() can throw errors and we recover what's partially loaded
from an image in the error handler.

(cherry picked from commit db08271d)
parent 0e61cb12
...@@ -765,7 +765,7 @@ on_read_error (png_structp png_ptr, ...@@ -765,7 +765,7 @@ on_read_error (png_structp png_ptr,
gint end; gint end;
gint num; gint num;
g_warning (_("Error loading PNG file: %s"), error_msg); g_printerr (_("Error loading PNG file: %s\n"), error_msg);
/* Flush the current half-read row of tiles */ /* Flush the current half-read row of tiles */
...@@ -1271,11 +1271,11 @@ load_image (const gchar *filename, ...@@ -1271,11 +1271,11 @@ load_image (const gchar *filename,
} }
} }
png_read_end (pp, info);
/* Switch back to default error handler */ /* Switch back to default error handler */
png_set_error_fn (pp, NULL, NULL, NULL); png_set_error_fn (pp, NULL, NULL, NULL);
png_read_end (pp, info);
if (png_get_text (pp, info, &text, &num_texts)) if (png_get_text (pp, info, &text, &num_texts))
{ {
gchar *comment = NULL; gchar *comment = NULL;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment