Re: [gtk-win32] g_idle_add() weirdness
- From: "John Emmas" <johne53 tiscali co uk>
- To: "Gtk+ on win32 platform packaging and distribution discussion" <gtk-win32-list gnome org>
- Subject: Re: [gtk-win32] g_idle_add() weirdness
- Date: Tue, 9 Feb 2010 18:21:07 -0000
----- Original Message -----
From: "Tor Lillqvist"
Could the fact that in pthreads-win32 pthread_t is not a pointer (or
some integral type), but a struct, have something to do with this? (I
mean, could this lead your code into wrongly identifying what thread
the callback is running in? The only correct way to compare pthread_t
values is pthread_equal().)
I don't think that's the problem but just to be sure, I changed the idle
function to look like this:-
pthread_t UIthreadID; // Global - gets set elsewhere in the program
gboolean MainWindow::idle_set_progress(gpointer _pValue)
{
// In theory, this function should be executing
// from within the GUI thread
if (pthread_equal (UIthreadID, pthread_self()))
{
if ((m_pProgress) && (_pValue))
{
double* pNewValue = static_cast<double*>(_pValue);
double new_value = *pNewValue;
m_pProgress->set_fraction (new_value);
}
}
return (false);
}
The above code results in the progress bar getting updated in the Linux and
Cygwin versions but not updated in the gtk-win32 version. So it still looks
like the code is being executed in the wrong thread. Here's how I set up
the worker thread. Is there possibly something wrong in my approach to
this? - n.b. assume that 'ThreadFunc()' is actually defined somewhere.
class WorkerThread
{
public:
static void* ThreadFunc (void*);
sigc::signal<void, double> m_sigNotify;
sigc::signal<void> m_sigFinished;
};
static WorkerThread Worker;
pthread_t UIthreadID, WTthreadID;
// All below is carried out in the main GUI thread
WTthreadID = UIthreadID = pthread_self();
int create_failed = pthread_create(&WTthreadID, 0,
&WorkerThread::ThreadFunc, &Worker);
if ((create_failed) || (pthread_equal(WTthreadID, UIthreadID)))
m_pButton->set_label ("Worker thread creation failed....");
If the above looks okay, I could produce a simplified program written only
in 'C' but I'm busy with another project for the next few days so it would
have to wait until the weekend.
Thanks,
John
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]