On Sun, Aug 06, 2006 at 02:33:41PM +0200, [EMAIL PROTECTED] wrote:
> Hi, unfortunately nobody seems to have an idea so far.

[...]

So many things, I don't know where to start...

> Hi, I have a problem with keeping an animated gif running while the gtk main 
> loop is blocked.
> The gif (called waitImage) is placed on a GtkDialog (waitDialog). The 
> GdkPixbufAnimation "behind" waitImage is called waitImageAnimated.
> I tried to do it like this:
> 
> while(...) {
>   gtk_widget_queue_draw(GTK_WIDGET (GTK_DIALOG (waitDlg)->vbox));
>   gdk_window_process_updates (gtk_widget_get_parent_window (GTK_DIALOG
>                                               (waitDlg)->vbox), true);
>   waitImagePixbuf = gdk_pixbuf_animation_iter_get_pixbuf(
>                   gdk_pixbuf_animation_get_iter(waitImageAnimated, NULL));
>   gtk_image_set_from_pixbuf(GTK_IMAGE (waitImage),waitImagePixbuf);

Here's the leak: on each round, you order an animation iterator with
gdk_pixbuf_animation_get_iter(...) just to throw it away without
unref()ing it.

The way to avoid this leak might be:

 |   GdkPixbufAnimationIter *iter = 
gdk_pixbuf_animation_get_iter(waitImageAnimated, NULL);
 |   while(...) {
 |     ...
 |    gtk_image_set_from_pixbuf(gdk_pixbuf_animation_iter_get_pixbuf(iter));
 |   }
 |   g_object_unref(G_OBJECT(iter));

As I understand the doc, you don't have to unref the pixbufs you get
from the iterator (but the iterator itself!). Plus you don't have to
dreate a new iterator on each round of your loop (I guess it would start
at the first image of the animation each time anyway).

But I don't understand why you try to do it all yourself. There is an
gtk_image_set_from_animation() which should just work for you (plus, if
you want to step all by yourself through the anim frames, maybe you
should do it in a timer or idle func, instead of doing the gtk loop by
hand and getting into hot water about that ;)

HTH
-- tomás
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Reply via email to