Fix incremental loading of xbms. (#346427, Ed Catmur) Also make the xbm

2006-07-16  Matthias Clasen  <mclasen@redhat.com>

	* io-xbm.c: Fix incremental loading of
	xbms.  (#346427, Ed Catmur)
	Also make the xbm loader accept const variations.
This commit is contained in:
Matthias Clasen 2006-07-17 01:57:56 +00:00 committed by Matthias Clasen
parent e8640b3e60
commit b8b28b6782
2 changed files with 34 additions and 18 deletions

View File

@ -1,3 +1,9 @@
2006-07-16 Matthias Clasen <mclasen@redhat.com>
* io-xbm.c: Fix incremental loading of
xbms. (#346427, Ed Catmur)
Also make the xbm loader accept const variations.
2006-07-02 Matthias Clasen <mclasen@redhat.com> 2006-07-02 Matthias Clasen <mclasen@redhat.com>
* === Released 2.10.0 === * === Released 2.10.0 ===

View File

@ -143,10 +143,12 @@ next_int (FILE *fstream)
} }
static gboolean static gboolean
read_bitmap_file_data (FILE *fstream, read_bitmap_file_data (FILE *fstream,
guint *width, guint *height, guint *width,
guint *height,
guchar **data, guchar **data,
int *x_hot, int *y_hot) int *x_hot,
int *y_hot)
{ {
guchar *bits = NULL; /* working variable */ guchar *bits = NULL; /* working variable */
char line[MAX_SIZE]; /* input line from file */ 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) if (sscanf (line, "static short %s = {", name_and_type) == 1)
version10p = 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) else if (sscanf (line,"static unsigned char %s = {",name_and_type) == 1)
version10p = 0; 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) else if (sscanf (line, "static char %s = {", name_and_type) == 1)
version10p = 0; version10p = 0;
else else
@ -267,7 +273,9 @@ read_bitmap_file_data (FILE *fstream,
static GdkPixbuf * 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; guint w, h;
int x_hot, y_hot; 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) {
if (context->update_func) if (context->update_func)
(* context->update_func) (pixbuf, 0, 0, w, h, context->user_data); (* context->update_func) (pixbuf, 0, 0, w, h, context->user_data);
g_object_unref (pixbuf);
pixbuf = NULL;
} }
return pixbuf; return pixbuf;
@ -351,7 +357,8 @@ gdk_pixbuf__xbm_image_load_real (FILE *f, XBMData *context, GError **error)
/* Static loader */ /* Static loader */
static GdkPixbuf * 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); 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 static gpointer
gdk_pixbuf__xbm_image_begin_load (GdkPixbufModuleSizeFunc size_func, gdk_pixbuf__xbm_image_begin_load (GdkPixbufModuleSizeFunc size_func,
GdkPixbufModulePreparedFunc prepare_func, GdkPixbufModulePreparedFunc prepare_func,
GdkPixbufModuleUpdatedFunc update_func, GdkPixbufModuleUpdatedFunc update_func,
gpointer user_data, gpointer user_data,
GError **error) GError **error)
{ {
XBMData *context; XBMData *context;
gint fd; gint fd;
@ -398,8 +405,8 @@ gdk_pixbuf__xbm_image_begin_load (GdkPixbufModuleSizeFunc size_func,
} }
static gboolean static gboolean
gdk_pixbuf__xbm_image_stop_load (gpointer data, gdk_pixbuf__xbm_image_stop_load (gpointer data,
GError **error) GError **error)
{ {
XBMData *context = (XBMData*) data; XBMData *context = (XBMData*) data;
gboolean retval = TRUE; gboolean retval = TRUE;
@ -410,10 +417,13 @@ gdk_pixbuf__xbm_image_stop_load (gpointer data,
rewind (context->file); rewind (context->file);
if (context->all_okay) { if (context->all_okay) {
GdkPixbuf *pixbuf; GdkPixbuf *pixbuf;
pixbuf = gdk_pixbuf__xbm_image_load_real (context->file, context, pixbuf = gdk_pixbuf__xbm_image_load_real (context->file,
context,
error); error);
if (pixbuf == NULL) if (pixbuf == NULL)
retval = FALSE; retval = FALSE;
else
g_object_unref (pixbuf);
} }
fclose (context->file); fclose (context->file);
@ -425,10 +435,10 @@ gdk_pixbuf__xbm_image_stop_load (gpointer data,
} }
static gboolean static gboolean
gdk_pixbuf__xbm_image_load_increment (gpointer data, gdk_pixbuf__xbm_image_load_increment (gpointer data,
const guchar *buf, const guchar *buf,
guint size, guint size,
GError **error) GError **error)
{ {
XBMData *context = (XBMData *) data; XBMData *context = (XBMData *) data;