RE: Problem with threads in my GTK+ application...




Hello,
I finally found out the solution to my problme and that too without
using threads.

In my burn code, after sending each byte, I am using:

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

This seems to have solved my problem. Even my progress bar gets updated
smoothly now.

But I would still like to know how to do this using threading.
I tried
http://research.operationaldynamics.com/blogs/andrew/software/gnome-desk
top/gtk-thread-awareness.html hoping it would solve my problem but even
that did not work :-(


regards,
Seemanta




-----Original Message-----
From: gtk-app-devel-list-bounces gnome org
[mailto:gtk-app-devel-list-bounces gnome org] On Behalf Of Andreas
Stricker
Sent: Friday, July 11, 2008 12:19 PM
To: gtk-app-devel-list gnome org
Subject: Re: Problem with threads in my GTK+ application...

Dutta, Seemanta schrieb:
The way I decided to remedy this problem was with the below steps:

1. Call g_thread_init() in the main function before gtk_init() is
called.
2. In the callback for 'clicked' signal for the'Burn' button, I use
g_thread_create() to create a new thread which will handle the burning
of the micro processor.
3. I immediately return from  the callback and control goes back to
the
main loop.

MY PROBLEM: With the above approach, my application works for the
first
time. It just works perfectly. All the logs in the textviewer come up
in
sync with the actual process. 

This looks as the usual problem: Your description sounds like you are
updating the textview from *within* the worker thread.
Although it's possible to update the GUI from more than one thread
this is not recommend, as it is tricky to do the locks the right way.
I suggest you should search this mailing list for threading, this
is discussed here nearly once a week.

Only when I press BURN for the second time, the textviwer does not
show
any logs, although I can see log statements in my console and it also
performs its work of programming the microprocessor.

The locking seem to be wrong...

I'll try to remove all Gtk calls from worker thread and only update
the GUI from main Gtk thread. The data for the log textviewer
can be sent with a thread save queue (with locking) or simple over
a pipe.

Cheers, Andy
_______________________________________________
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]