From b8b28b6782d19b3e7657df9e7484550a7035a01c Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Mon, 17 Jul 2006 01:57:56 +0000 Subject: [PATCH] Fix incremental loading of xbms. (#346427, Ed Catmur) Also make the xbm 2006-07-16 Matthias Clasen * io-xbm.c: Fix incremental loading of xbms. (#346427, Ed Catmur) Also make the xbm loader accept const variations. --- gdk-pixbuf/ChangeLog | 6 ++++++ gdk-pixbuf/io-xbm.c | 46 +++++++++++++++++++++++++++----------------- 2 files changed, 34 insertions(+), 18 deletions(-) diff --git a/gdk-pixbuf/ChangeLog b/gdk-pixbuf/ChangeLog index fe6b021695..a0624ad311 100644 --- a/gdk-pixbuf/ChangeLog +++ b/gdk-pixbuf/ChangeLog @@ -1,3 +1,9 @@ +2006-07-16 Matthias Clasen + + * io-xbm.c: Fix incremental loading of + xbms. (#346427, Ed Catmur) + Also make the xbm loader accept const variations. + 2006-07-02 Matthias Clasen * === Released 2.10.0 === diff --git a/gdk-pixbuf/io-xbm.c b/gdk-pixbuf/io-xbm.c index 5fe2cafdd0..19d0e20d5d 100644 --- a/gdk-pixbuf/io-xbm.c +++ b/gdk-pixbuf/io-xbm.c @@ -143,10 +143,12 @@ next_int (FILE *fstream) } static gboolean -read_bitmap_file_data (FILE *fstream, - guint *width, guint *height, +read_bitmap_file_data (FILE *fstream, + guint *width, + guint *height, guchar **data, - int *x_hot, int *y_hot) + int *x_hot, + int *y_hot) { guchar *bits = NULL; /* working variable */ char line[MAX_SIZE]; /* input line from file */ @@ -198,8 +200,12 @@ read_bitmap_file_data (FILE *fstream, if (sscanf (line, "static short %s = {", name_and_type) == 1) version10p = 1; + else if (sscanf (line,"static const unsigned char %s = {",name_and_type) == 1) + version10p = 0; else if (sscanf (line,"static unsigned char %s = {",name_and_type) == 1) version10p = 0; + else if (sscanf (line, "static const char %s = {", name_and_type) == 1) + version10p = 0; else if (sscanf (line, "static char %s = {", name_and_type) == 1) version10p = 0; else @@ -267,7 +273,9 @@ read_bitmap_file_data (FILE *fstream, static GdkPixbuf * -gdk_pixbuf__xbm_image_load_real (FILE *f, XBMData *context, GError **error) +gdk_pixbuf__xbm_image_load_real (FILE *f, + XBMData *context, + GError **error) { guint w, h; int x_hot, y_hot; @@ -340,8 +348,6 @@ gdk_pixbuf__xbm_image_load_real (FILE *f, XBMData *context, GError **error) if (context) { if (context->update_func) (* context->update_func) (pixbuf, 0, 0, w, h, context->user_data); - g_object_unref (pixbuf); - pixbuf = NULL; } return pixbuf; @@ -351,7 +357,8 @@ gdk_pixbuf__xbm_image_load_real (FILE *f, XBMData *context, GError **error) /* Static loader */ static GdkPixbuf * -gdk_pixbuf__xbm_image_load (FILE *f, GError **error) +gdk_pixbuf__xbm_image_load (FILE *f, + GError **error) { return gdk_pixbuf__xbm_image_load_real (f, NULL, error); } @@ -365,11 +372,11 @@ gdk_pixbuf__xbm_image_load (FILE *f, GError **error) */ static gpointer -gdk_pixbuf__xbm_image_begin_load (GdkPixbufModuleSizeFunc size_func, - GdkPixbufModulePreparedFunc prepare_func, - GdkPixbufModuleUpdatedFunc update_func, - gpointer user_data, - GError **error) +gdk_pixbuf__xbm_image_begin_load (GdkPixbufModuleSizeFunc size_func, + GdkPixbufModulePreparedFunc prepare_func, + GdkPixbufModuleUpdatedFunc update_func, + gpointer user_data, + GError **error) { XBMData *context; gint fd; @@ -398,8 +405,8 @@ gdk_pixbuf__xbm_image_begin_load (GdkPixbufModuleSizeFunc size_func, } static gboolean -gdk_pixbuf__xbm_image_stop_load (gpointer data, - GError **error) +gdk_pixbuf__xbm_image_stop_load (gpointer data, + GError **error) { XBMData *context = (XBMData*) data; gboolean retval = TRUE; @@ -410,10 +417,13 @@ gdk_pixbuf__xbm_image_stop_load (gpointer data, rewind (context->file); if (context->all_okay) { GdkPixbuf *pixbuf; - pixbuf = gdk_pixbuf__xbm_image_load_real (context->file, context, + pixbuf = gdk_pixbuf__xbm_image_load_real (context->file, + context, error); if (pixbuf == NULL) retval = FALSE; + else + g_object_unref (pixbuf); } fclose (context->file); @@ -425,10 +435,10 @@ gdk_pixbuf__xbm_image_stop_load (gpointer data, } static gboolean -gdk_pixbuf__xbm_image_load_increment (gpointer data, +gdk_pixbuf__xbm_image_load_increment (gpointer data, const guchar *buf, - guint size, - GError **error) + guint size, + GError **error) { XBMData *context = (XBMData *) data;