self-removing timeouts
- From: Havoc Pennington <hp pobox com>
- To: gtk-list redhat com
- Subject: self-removing timeouts
- Date: Sun, 29 Mar 1998 02:22:00 -0600 (CST)
Hi,
Hoping someone can enlighten me on timeouts a little.
It seems that I can't remove a timeout from within the timeout:
#include <gtk--.h>
#include <iostream.h>
gint timeout;
gint iteration(gpointer data)
{
static int num_iterations = 0;
cerr << "Iteration...";
++num_iterations;
if (num_iterations == 15) {
cerr << "Stopping...";
((Gtk_Main *)data)->timeout_remove(timeout);
// return false; // this would work
}
return true;
}
int main(int argc, char ** argv)
{
Gtk_Main m(&argc, &argv);
timeout = m.timeout_add(100, iteration, &m);
m.run();
}
This just keeps on going forever, without so much as a
warning. Timeout removal works in testgtk, and the above program can
be made to work with a "return false," I think.
However, in my program the timeout sometimes causes a signal to be
emitted which calls a function to remove the timeout, so the return
false would have to happen via some roundabout mechanism.
Is returning false the only way to remove a timeout from within a
timeout? Is timeout_remove() explicitly disallowed from inside the
timeout? The tutorial makes it sound like "return false" is a
convenience thing and never required.
Thanks,
Havoc Pennington
http://pobox.com/~hp
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]