Recent

Author Topic: Dialog LCL controls (Mac, 64bit) not updating within a routine  (Read 1196 times)

yazzdi

  • New Member
  • *
  • Posts: 16
On Delphi (Windows), (and 32 bit Mac LCL as I recall), dialog controls could be updated within a routine.

For example...
Procedure TMyDialog.DoSomething
begin
Self.Caption:='Hello World';
DoSomethingTimeConsuming;
end;

In Delphi (and 32 bit LCL as I recall), the dialog caption would update to "Hello World" before the DoSomethingTimeConsuming routine was called. But with Mac LCL 64-bit (using latest August12 trunk), the dialog caption (or any other dialog control) doesn't update until the routine is finished.

A workaround is to pepper the code with Application.ProcessMessages;

Procedure TMyDialog.DoSomething
begin
Self.Caption:='Hello World';
Application.ProcessMessages; //this updates the Caption
DoSomethingTimeConsuming;
end;

But I'm wondering if this is an intentional change or a bug, or I've done something wrong? There's a much appreciated compatibility between Delphi and LCL code, so it would be a shame for this to be a difference.
« Last Edit: August 14, 2019, 11:06:26 pm by yazzdi »

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: Dialog LCL controls (Mac, 64bit) not updating within a routine
« Reply #1 on: August 14, 2019, 11:04:14 pm »
In Delphi (and 32 bit LCL as I recall), the dialog caption would update to "Hello World" before the DoSomethingTimeConsuming routine was called. But with Mac LCL 64-bit (using latest August12 trunk), the dialog caption (or any other dialog control) doesn't update until the routine is finished.
...
A workaround is to pepper the code with Application.ProcessMessages;
...
wondering if this is an intentional change or a bug, or I've done something wrong?
This is a double-buffered drawing and it's mandatory for Cocoa.

Drawing should only occur is paint event. Changing the text on a control caption is a legal action, but you will only see the change after the next paint event finishes.

That's why adding Application.ProcessMessages does the trick. It forces the call for the next paint event.

How to fix it: rewrite the code, so it doesn't require re-paintings during OnButtonClick or similar.
or stuff the code with enough Application.ProcessMessages, which has its own complexity.
Threading, anyone?
« Last Edit: August 14, 2019, 11:06:17 pm by skalogryz »

yazzdi

  • New Member
  • *
  • Posts: 16
Re: Dialog LCL controls (Mac, 64bit) not updating within a routine
« Reply #2 on: August 14, 2019, 11:14:01 pm »
Thanks for the helpful reply, and explanation about Cocoa requiring this. I'll use the Applications.ProcessMessages.

As an aside, Mac LCL 64-bit latest trunks are looking and working great, and we really appreciate the work that the Team is doing. Thanks!
« Last Edit: August 14, 2019, 11:16:01 pm by yazzdi »

 

TinyPortal © 2005-2018