Re: g_idle_add_full and main loop



On Wed, 2005-08-31 at 12:53 +0200, PaweÅ RÃÅaÅski wrote:
Hi,

I'm digging for an answer and I can't find it.

I Have two threads, but they are native Windows threads (I use 2.6.8
on winXP). One of them is standard GTK main loop, the other one is a
callback from external library. So i made it like


int func(data)
{
      gtk_label_set_text(GTK_LABEL(lab), "something");
      gdk_window_process_all_updates();
  return false;
}

callback()
{
 ..
  g_idle_add_full(G_PRIORITY_HIGH_IDLE, &func, NULL,NULL);
..
}


And It works... well sort off. func get called right away only if i
constantly move mouse pointer over my gtk application (i suspect this
triggers pending events). I want to have fired that func right away,
since it's a "progress" (its called about once for second).

Sorry if it's on mailing list but seraching "threads GUI" didn't bring
me detailed answer. In faq there is a "g_idle_add_full" trick like
this one but there is nothing about my problem with lazyness of that
approach.

I'm thinking of g_signal to main loop or something but.... well....
maybe there is an elegant solution.

Sounds like potentially a bug in the Win32 main loop code in GLib.
Adding an idle source should wake up the the thread that is waiting
for incoming events; there is a semaphore for this function.

Can you create a small standalone test case? (and preferably put
it in bugzilla)

Thanks,
                                                Owen

P.S. -  guess one question is - did you call g_thread_init()? 
That is needed for correct operation of GLib from a threaded 
program.



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