[gdk-pixbuf] Never pass NULL for the size_func and updated_func of module->begin_load()



commit ab792e3768536705f9dd379cd12faf78f770aff8
Author: Federico Mena Quintero <federico gnome org>
Date:   Tue Nov 28 19:07:50 2017 -0600

    Never pass NULL for the size_func and updated_func of module->begin_load()
    
    This will let us avoid NULL checks in the individual modules.

 gdk-pixbuf/gdk-pixbuf-animation.c | 19 ++++++++++++++++++-
 gdk-pixbuf/gdk-pixbuf-io.c        | 19 ++++++++++++++++++-
 2 files changed, 36 insertions(+), 2 deletions(-)
---
diff --git a/gdk-pixbuf/gdk-pixbuf-animation.c b/gdk-pixbuf/gdk-pixbuf-animation.c
index 66a037c20..c8f2695e3 100644
--- a/gdk-pixbuf/gdk-pixbuf-animation.c
+++ b/gdk-pixbuf/gdk-pixbuf-animation.c
@@ -105,6 +105,13 @@ gdk_pixbuf_animation_init (GdkPixbufAnimation *animation)
 {
 }
 
+static void
+noop_size_notify (gint     *width,
+                 gint     *height,
+                 gpointer  data)
+{
+}
+
 static void
 prepared_notify (GdkPixbuf          *pixbuf,
                  GdkPixbufAnimation *anim,
@@ -118,6 +125,16 @@ prepared_notify (GdkPixbuf          *pixbuf,
         *((GdkPixbufAnimation **)user_data) = anim;
 }
 
+static void
+noop_updated_notify (GdkPixbuf *pixbuf,
+                     int        x,
+                     int        y,
+                     int        width,
+                     int        height,
+                     gpointer   user_data)
+{
+}
+
 /**
  * gdk_pixbuf_animation_new_from_file:
  * @filename: (type filename): Name of file to load, in the GLib file
@@ -221,7 +238,7 @@ gdk_pixbuf_animation_new_from_file (const gchar  *filename,
                 animation = NULL;
                fseek (f, 0, SEEK_SET);
 
-                context = image_module->begin_load (NULL, prepared_notify, NULL, &animation, error);
+                context = image_module->begin_load (noop_size_notify, prepared_notify, noop_updated_notify, 
&animation, error);
                 if (!context)
                         goto fail_begin_load;
 
diff --git a/gdk-pixbuf/gdk-pixbuf-io.c b/gdk-pixbuf/gdk-pixbuf-io.c
index 17ceb59df..ce0ed633f 100644
--- a/gdk-pixbuf/gdk-pixbuf-io.c
+++ b/gdk-pixbuf/gdk-pixbuf-io.c
@@ -1006,6 +1006,13 @@ _gdk_pixbuf_get_module_for_file (FILE *f, const gchar *filename, GError **error)
        return _gdk_pixbuf_get_module (buffer, size, filename, error);
 }
 
+static void
+noop_size_notify (gint     *width,
+                 gint     *height,
+                 gpointer  data)
+{
+}
+
 static void
 prepared_notify (GdkPixbuf *pixbuf, 
                  GdkPixbufAnimation *anim, 
@@ -1016,13 +1023,23 @@ prepared_notify (GdkPixbuf *pixbuf,
         *((GdkPixbuf **)user_data) = pixbuf;
 }
 
+static void
+noop_updated_notify (GdkPixbuf *pixbuf,
+                    int        x,
+                    int        y,
+                    int        width,
+                    int        height,
+                    gpointer   user_data)
+{
+}
+
 static GdkPixbuf *
 generic_load_incrementally (GdkPixbufModule *module, FILE *f, GError **error)
 {
         GdkPixbuf *pixbuf = NULL;
        gpointer context;
 
-       context = module->begin_load (NULL, prepared_notify, NULL, &pixbuf, error);
+       context = module->begin_load (noop_size_notify, prepared_notify, noop_updated_notify, &pixbuf, error);
         
        if (!context)
                goto out;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]