Stop loading an animation if the first frame is complete. (#350911,

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

	* gdk-pixbuf-io.c (gdk_pixbuf_new_from_file_at_scale):
	Stop loading an animation if the first frame is complete.
	(#350911, Christian Neumair)
This commit is contained in:
Matthias Clasen 2006-08-16 06:01:09 +00:00 committed by Matthias Clasen
parent 423b7ae24e
commit b34a2576d1
2 changed files with 21 additions and 2 deletions

View File

@ -1,3 +1,9 @@
2006-08-16 Matthias Clasen <mclasen@redhat.com>
* gdk-pixbuf-io.c (gdk_pixbuf_new_from_file_at_scale):
Stop loading an animation if the first frame is complete.
(#350911, Christian Neumair)
2006-07-23 Matthias Clasen <mclasen@redhat.com>
* === Released 2.10.1 ===

View File

@ -1095,6 +1095,9 @@ gdk_pixbuf_new_from_file_at_scale (const char *filename,
gint height;
gboolean preserve_aspect_ratio;
} info;
GdkPixbufAnimation *animation;
GdkPixbufAnimationIter *iter;
gboolean has_frame;
g_return_val_if_fail (filename != NULL, NULL);
g_return_val_if_fail (width > 0 || width == -1, NULL);
@ -1122,7 +1125,8 @@ gdk_pixbuf_new_from_file_at_scale (const char *filename,
g_signal_connect (loader, "size-prepared", G_CALLBACK (size_prepared_cb), &info);
while (!feof (f) && !ferror (f)) {
has_frame = FALSE;
while (!has_frame && !feof (f) && !ferror (f)) {
length = fread (buffer, 1, sizeof (buffer), f);
if (length > 0)
if (!gdk_pixbuf_loader_write (loader, buffer, length, error)) {
@ -1131,11 +1135,20 @@ gdk_pixbuf_new_from_file_at_scale (const char *filename,
g_object_unref (loader);
return NULL;
}
animation = gdk_pixbuf_loader_get_animation (loader);
if (animation) {
iter = gdk_pixbuf_animation_get_iter (animation, 0);
if (!gdk_pixbuf_animation_iter_on_currently_loading_frame (iter)) {
has_frame = TRUE;
}
g_object_unref (iter);
}
}
fclose (f);
if (!gdk_pixbuf_loader_close (loader, error)) {
if (!gdk_pixbuf_loader_close (loader, error) && !has_frame) {
g_object_unref (loader);
return NULL;
}