Re: Animation problem
- From: "Norbert Bauer" <dasaspock gmx de>
- To: gtk-app-devel-list gnome org
- Subject: Re: Animation problem
- Date: Sun, 06 Aug 2006 17:53:29 +0200
Thank you very much!
Like this it's now working and seems korrekt :-)
GdkPixbufAnimationIter *animIter = gdk_pixbuf_animation_get_iter
(waitImageAnimated, NULL);
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);
gdk_pixbuf_animation_iter_advance (animIter,NULL);
waitImagePixbuf = gdk_pixbuf_animation_iter_get_pixbuf(animIter);
gtk_image_set_from_pixbuf(GTK_IMAGE (waitImage),waitImagePixbuf);
}
g_object_unref(G_OBJECT(animIter));
dasaspock
-------- Original-Nachricht --------
Datum: Sun, 6 Aug 2006 13:05:10 +0000
Von: tomas tuxteam de
An: dasaspock gmx de
Betreff: Re: Fwd: Animation problem
On Sun, Aug 06, 2006 at 02:33:41PM +0200, dasaspock gmx de 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
--
Echte DSL-Flatrate dauerhaft für 0,- Euro*. Nur noch kurze Zeit!
"Feel free" mit GMX DSL: http://www.gmx.net/de/go/dsl
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]