Re: Weird problems: C library programs crashing in combination with GTK UI
- From: "Michael Lamothe" <michael lamothe gmail com>
- To: gtk-app-devel-list gnome org
- Subject: Re: Weird problems: C library programs crashing in combination with GTK UI
- Date: Wed, 23 Jan 2008 10:18:20 +1100
Hi,
Alternatively, you can use the new gdk_threads_add_timeout() available
in GTK 2.12. It's a GDK thread safe drop-in-replacement for
g_timeout_add().
Thanks,
Michael
On 23/01/2008, Tristan Van Berkom <tvb gnome org> wrote:
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
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]