|
Setup: I am getting conflicting information between the free pascal wiki and user comments on the lazarus forum. The wiki states it is ok to use Application.ProcessMessages instead of threads while responses on forum contradict that opinion. Because of that, I may switch to using threads, but as of right now, I am converting some code from lazarus which uses Application.ProcessMessages. What the code does, is sets the caption of a label to show something like "Processing", then performs the process and then resets the caption to "Done". It calls Application.ProcessMessages to update the UI with the new caption. I tried to do this in fpgui using: but the UI does not update. Does the fpgui version of ProcessMessages work differently or does setting Text not create a message? As I mentioned, this might be moot as I am probably going to convert to using threads, but thought I would ask anyway. Thanks, |
Replies: 1 comment 2 replies
|
Hi Steve, Thanks for the report — this turned out to be a genuine bug in fpGUI, not a misunderstanding on your part. Your instinct was right: What was going wrongfpGUI has two message queues, and Setting In Lazarus this works because the LCL drains its queue unconditionally and hands damage straight to GTK/Qt, which track it natively. fpGUI's own queue is invisible to Fixed
Landed on On threadsFor a status label around a long operation, If the work is genuinely long-running and you want the UI responsive throughout, threads are the better structure. fpGUI has Thanks again for raising it — clear enough to reproduce from, and this one had been lurking a while. Graeme |
Hi Steve,
Thanks for the report — this turned out to be a genuine bug in fpGUI, not a misunderstanding on your part. Your instinct was right:
Label.Text := ...followed byfpgApplication.ProcessMessagesshould update the UI, and it wasn't.What was going wrong
fpGUI has two message queues, and
ProcessMessageswas only checking one.Setting
Label.Textposts an internalFPGM_PAINTmessage onto fpGUI's own queue — it generates no X11 event. ButProcessMessagesgated its whole body onMessagesPending, which on X11 is justXPending(display) > 0, i.e. native events only. With no X events pending the loop never ran, the internal queue was never drained, and the paint sat there until the app retu…