Re: Dealing with outstanding timeout callbacks



Braden McDaniel wrote...
[...]
I think I've figured it out. I am doing

        while (gtk_events_pending()) { gtk_main_iteration(); }

as part of my update loop as well; I do it right before I call
g_timeout_add, in fact. So I yield to process GTK events, one of those
destroys my widget; and poof, there goes the world out from under my
function. But it proceeds to add another timeout because the timeout_id
is 0 (though the timeout_id is freed memory at that point).

So my question is, what's the GTK Way of handling this sort of thing?

Why is there a
    while (gtk_events_pending()) { gtk_main_iteration(); }
line ?

In some places it is nescisary to sync the main loop like that but the more
that you do that kind of thing the more your program gets complicated
(in some cases, as you've just discovered).

Is it possible to get away with only calling 
    gdk_window_process_updates (); ?

Cheers,
                                      -Tristan



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]