Lazarus

Programming => Widgetset => Cocoa => Topic started by: VTwin on May 05, 2019, 11:22:46 pm

Title: [Solved] TUpDown gives bad access
Post by: VTwin on May 05, 2019, 11:22:46 pm
When setting TUpDown.Enabled bad access occurs in:

Code: Pascal  [Select]
  1. procedure TCustomUpDown.SetEnabled(Value: Boolean);
  2. begin
  3.   FMinBtn.Enabled := Value;
  4.   FMaxBtn.Enabled := Value;
  5.   inherited SetEnabled(Value);
  6. end;

Example project attached, using Cocoa trunk. I'd appreciate any comments before filing a bug report.

Thanks,
VTwin
Title: Re: TUpDown gives bad access
Post by: Hansaplast on May 06, 2019, 10:08:24 am
Just tested it with Lazarus 2.1.0 r61037M FPC 3.0.4 x86_64-darwin-cocoa (alpha) under macOS Mojave 10.14.4.


I can confirm your finding.
You project produces an Access Violation when assigning a boolean to the enabled property.
I've tried it with a straight "false" as well, and that caused the same error.


I just tried updating from svn, but cannot get the IDE compiled with the latest version;


Code: Pascal  [Select]
  1. ...
  2.  
  3. application.inc(560,13) Warning: Symbol "AppHandle" is not portable
  4. Assembling (pipe) units/x86_64-darwin/forms.s
  5. controls.pp(3099,3) Note: Local variable "LastFrm" is assigned but never used
  6. Assembling (pipe) units/x86_64-darwin/controls.s
  7. controls.pp(4648) Fatal: Internal error 2013121801
  8. Fatal: Compilation aborted
  9. make[1]: *** [alllclunits.ppu] Error 1
  10. make: *** [lazbuild] Error 2
Title: Re: TUpDown gives bad access
Post by: Hansaplast on May 06, 2019, 10:27:00 am

Tested this with Lazarus 2.1.0 r61158M FPC 3.0.4 x86_64-darwin-cocoa (alpha) as well.
Same result.
Title: Re: TUpDown gives bad access
Post by: VTwin on May 06, 2019, 04:03:27 pm
Thanks Hansaplast. Reported:

https://bugs.freepascal.org/view.php?id=35531

I'll guess this happened when skalogryz implemented it as a native control, the Enabled method may have been overlooked.

According to his blog, all other UpDown controls are non-native. I assume FMinBtn and FMaxBtn were separate buttons, which no longer exist in Cocoa.

I agree with him that the native Cocoa control looks much better than the non-native one used in Carbon.

Until fixed I'll use a workaround:

Code: Pascal  [Select]
  1. procedure TForm1.UpDown1Click(Sender: TObject; Button: TUDBtnType);
  2. begin
  3.   if not Edit1.Enabled then
  4.     exit;
  5.   // increment value in Edit1
  6. end;





Title: Re: TUpDown gives bad access
Post by: Hansaplast on May 06, 2019, 04:36:25 pm

You're welcome, thanks for posting a bug!
(anything to improve Cocoa)


I'd prefer native controls as well. Never really like the non-native up/down control all that much.


I did not know skalogryz had a blog? Do you have a link?
Title: Re: TUpDown gives bad access
Post by: VTwin on May 06, 2019, 06:57:20 pm
You may already have seen it, I was referring to his "Patreon" page:

https://www.patreon.com/skalogryz


The native Cocoa TUpDown only displays vertically. I was using horizontal, as vertical looked cramped next to a TEdit. I changed them all to vertical now, although it looks cramped (to me) on Windows and Linux. Good enough though, the Anchor Editor uses them.
Title: Re: TUpDown gives bad access
Post by: Hansaplast on May 07, 2019, 05:23:47 pm
Ah, OK, I didn't realize the Patreon.com page was used by Dmitry to post updates.  :-[


I just update Lazarus from SVn, and it compiles correctly now and the Up-Down does look good enough to me.  :)
Title: Re: TUpDown gives bad access
Post by: skalogryz on May 08, 2019, 05:02:46 am
Ah, OK, I didn't realize the Patreon.com page was used by Dmitry to post updates.  :-[
I don't. svn log is the blog
Title: Re: TUpDown gives bad access
Post by: Hansaplast on May 08, 2019, 10:29:32 am
I don't. svn log is the blog


Oh OK, sorry for misunderstanding that and thanks for clarifying Skalogryz! :)
Title: Re: TUpDown gives bad access
Post by: VTwin on May 12, 2019, 05:08:53 pm
I just update Lazarus from SVn, and it compiles correctly now and the Up-Down does look good enough to me.  :)

Yes, it has been fixed, and I closed the bug report. :)