On 12/01/11 15:48, [email protected] wrote:
On Wed, 12 Jan 2011, Graeme Geldenhuys wrote:
Op 2011-01-12 17:13, Michael Schnell het geskryf:
TThread.Synchronize seems to work fine with fpGUI, but with gtk2 I only
see events when I (e.g.) move the move around on Form.
@Michael van Canneyt
Now I don't feel so bad. ;-)
Yes, I thought this would cheer you up :-)
I suspect the GTK2 issue has to do with the changed glib main loop
behaviour.
It also messes up D-BUS stuff, but I'm still trying to debug that one; I
need to recompile the LCL each time with a different define
(USE_GTK_MAIN_OLD_ITERATION)
to compare main loops :/
Seems like TThread.Synchronize should wake up the GTK main loop.
The WakeMainThread handler is set for this to happen, but somehow nothing
happens.
The following code in gtk2winapi.inc wakes up the main loop when a
message is posted from a different thread (needs -dusecthreads):
{$IFNDEF USE_GTK_MAIN_OLD_ITERATION}
if GetCurrentThreadId <> MainThreadID then
begin
// old glib versions needs another way to wake up.
if (glib_major_version = 2) and
(glib_minor_version < 24) and (FMainPoll <> nil) then
FMainPoll^.revents := 1;
g_main_context_wakeup(g_main_context_default);
end;
{$ENDIF}
This seems to do the right thing for me when doing a postmessage from an
external thread.
The main loop should be woken up like this after QueueAsyncCall, too, imo.
Henry
--
_______________________________________________
Lazarus mailing list
[email protected]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus