Re: interrupting a big loop



On Wed, 19 May 2004 14:23:11 -0400 (EDT)
Allin Cottrell <cottrell wfu edu> wrote:

expensive_callback(some_object... data) {
     gboolean should_stop;
     gulong        sigid;
     should_stop = FALSE;
     sigid = g_signal_connect(cancel_button, "clicked",
                              on_cancel_button_clicked, &should_stop);
     for (;;) {
         /* ...
          */
         if (*should_stop) break;
         /* ...
          */
     }
     g_signal_disconnect(cancel_button, sigid);
}

Q: for this to work, there should at least a call to gtk_main_iteration
inside the loop too? Else the events won't be able to set the variable.

John



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