If neither load nor begin_load are available fall back to load_animation

Sun Nov  9 23:07:05 2003  Matthias Clasen  <maclas@gmx.de>

	* gdk-pixbuf-io.c (_gdk_pixbuf_generic_image_load): If neither
	load nor begin_load are available fall back to load_animation
	and use gdk_pixbuf_animation_get_static_image() to obtain a
	pixbuf. Inefficient, but at least doesn't crash.
This commit is contained in:
Matthias Clasen
2003-11-09 22:08:33 +00:00
committed by Matthias Clasen
parent 0af9579ea2
commit 95f163d7d2
2 changed files with 45 additions and 19 deletions

View File

@ -1,3 +1,10 @@
Sun Nov 9 23:07:05 2003 Matthias Clasen <maclas@gmx.de>
* gdk-pixbuf-io.c (_gdk_pixbuf_generic_image_load): If neither
load nor begin_load are available fall back to load_animation
and use gdk_pixbuf_animation_get_static_image() to obtain a
pixbuf. Inefficient, but at least doesn't crash.
Sun Nov 9 21:56:20 2003 Matthias Clasen <maclas@gmx.de> Sun Nov 9 21:56:20 2003 Matthias Clasen <maclas@gmx.de>
* queryloaders.c (write_loader_info): New function to write * queryloaders.c (write_loader_info): New function to write

View File

@ -647,34 +647,53 @@ _gdk_pixbuf_generic_image_load (GdkPixbufModule *module,
guchar buffer[4096]; guchar buffer[4096];
size_t length; size_t length;
GdkPixbuf *pixbuf = NULL; GdkPixbuf *pixbuf = NULL;
GdkPixbufAnimation *animation = NULL;
gpointer context; gpointer context;
if (module->load != NULL) if (module->load != NULL)
return (* module->load) (f, error); return (* module->load) (f, error);
context = module->begin_load (NULL, prepared_notify, NULL, &pixbuf, error); if (module->begin_load != NULL) {
if (!context) context = module->begin_load (NULL, prepared_notify, NULL, &pixbuf, error);
return NULL;
while (!feof (f)) { if (!context)
length = fread (buffer, 1, sizeof (buffer), f); return NULL;
if (length > 0)
if (!module->load_increment (context, buffer, length, error)) { while (!feof (f)) {
module->stop_load (context, NULL); length = fread (buffer, 1, sizeof (buffer), f);
if (pixbuf != NULL) if (length > 0)
g_object_unref (pixbuf); if (!module->load_increment (context, buffer, length, error)) {
return NULL; module->stop_load (context, NULL);
} if (pixbuf != NULL)
g_object_unref (pixbuf);
return NULL;
}
}
if (!module->stop_load (context, error)) {
if (pixbuf != NULL)
g_object_unref (pixbuf);
return NULL;
}
return pixbuf;
} }
if (!module->stop_load (context, error)) { if (module->load_animation != NULL) {
if (pixbuf != NULL) animation = (* module->load_animation) (f, error);
g_object_unref (pixbuf); if (animation != NULL) {
return NULL; pixbuf = gdk_pixbuf_animation_get_static_image (animation);
g_object_ref (pixbuf);
g_object_unref (animation);
return pixbuf;
}
} }
return pixbuf; return NULL;
} }
/** /**