[gdk-pixbuf] tests: Fix a couple of mistakes in pixbuf-save-ref
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gdk-pixbuf] tests: Fix a couple of mistakes in pixbuf-save-ref
- Date: Wed, 28 Dec 2016 17:39:46 +0000 (UTC)
commit 201079960809a9ca9aa2552c3433fce94e851b00
Author: Bastien Nocera <hadess hadess net>
Date: Wed Dec 28 18:13:38 2016 +0100
tests: Fix a couple of mistakes in pixbuf-save-ref
Fix incorrect _close()/_get_pixbuf() call order, a possible
g_object_unref() on a NULL pixbuf, and handling of GIF animations.
tests/pixbuf-save-ref.c | 19 ++++++++++++-------
1 files changed, 12 insertions(+), 7 deletions(-)
---
diff --git a/tests/pixbuf-save-ref.c b/tests/pixbuf-save-ref.c
index e805c13..253d9ab 100644
--- a/tests/pixbuf-save-ref.c
+++ b/tests/pixbuf-save-ref.c
@@ -25,7 +25,7 @@
static gboolean
load_and_save (const char *filename, GError **error)
{
- GdkPixbuf *pixbuf;
+ GdkPixbuf *pixbuf = NULL;
GdkPixbufLoader *loader;
guchar *contents;
char *new_filename = NULL;
@@ -42,15 +42,20 @@ load_and_save (const char *filename, GError **error)
goto out;
}
+ if (!gdk_pixbuf_loader_close (loader, error))
+ {
+ if (!g_error_matches (*error, GDK_PIXBUF_ERROR, GDK_PIXBUF_ERROR_INCOMPLETE_ANIMATION))
+ {
+ ret = FALSE;
+ goto out;
+ }
+ g_clear_error (error);
+ }
+
pixbuf = gdk_pixbuf_loader_get_pixbuf (loader);
g_assert (pixbuf);
g_object_ref (pixbuf);
- if (!gdk_pixbuf_loader_close (loader, error))
- {
- ret = FALSE;
- goto out;
- }
g_object_unref (loader);
new_filename = g_strdup_printf ("%s.ref.png", filename);
@@ -59,7 +64,7 @@ load_and_save (const char *filename, GError **error)
out:
g_free (contents);
g_free (new_filename);
- g_object_unref (pixbuf);
+ g_clear_object (&pixbuf);
return ret;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]