Re: Weird problems: C library programs crashing in combination with GTK UI



2008/1/22 <vijayasarathy setsindia net>:
[...]


Pseudo code for my call back function [for some button which will initiate
action] is as follows:

/***************CALL BACK FUNCTION CODE SNIPPET ***********************/
g_timeout_add(1500,progress_timeout,progressbarwidget);

f1();//THE BIG FUNCTION WHICH WILL RUN CLOSE TO A FEW HOURS

while (gtk_events_pending ())
{
       g_print("[.]");
       gtk_main_iteration ();
}//THIS SO THAT THE TIME OUT FUNCTION WILL BE ABLE TO CALL ITSELF

/****************END CALL BACK FUNCTION CODE
SNIPPET**********************/


Gtk+ runs in a single thread, you must return to the mainloop that
you are running (in gtk_main()) in order for your callbacks to be called.

If you dont want to split up f1(); into iterations and run those short
iterations from a timeout function, then you might consider using GThread.

You can also use the old hack:
====================
while (gtk_events_pending ())
       gtk_main_iteration ();
====================
to run the mainloop recursively so to speak, but if you never call
gtk_main_iteration() until you are finished f1(); then you are not
pushing progress bars.

Cheers,
                           -Tristan



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