Recent

Author Topic: [Solved] TUpDown gives bad access  (Read 2421 times)

VTwin

  • Hero Member
  • *****
  • Posts: 1215
  • Former Turbo Pascal 3 user
[Solved] TUpDown gives bad access
« 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
« Last Edit: May 12, 2019, 05:10:03 pm by VTwin »
“Talk is cheap. Show me the code.” -Linus Torvalds

Free Pascal Compiler 3.2.2
macOS 12.1: Lazarus 2.2.6 (64 bit Cocoa M1)
Ubuntu 18.04.3: Lazarus 2.2.6 (64 bit on VBox)
Windows 7 Pro SP1: Lazarus 2.2.6 (64 bit on VBox)

Hansaplast

  • Hero Member
  • *****
  • Posts: 674
  • Tweaking4All.com
    • Tweaking4All
Re: TUpDown gives bad access
« Reply #1 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

Hansaplast

  • Hero Member
  • *****
  • Posts: 674
  • Tweaking4All.com
    • Tweaking4All
Re: TUpDown gives bad access
« Reply #2 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.

VTwin

  • Hero Member
  • *****
  • Posts: 1215
  • Former Turbo Pascal 3 user
Re: TUpDown gives bad access
« Reply #3 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;





« Last Edit: May 06, 2019, 04:09:09 pm by VTwin »
“Talk is cheap. Show me the code.” -Linus Torvalds

Free Pascal Compiler 3.2.2
macOS 12.1: Lazarus 2.2.6 (64 bit Cocoa M1)
Ubuntu 18.04.3: Lazarus 2.2.6 (64 bit on VBox)
Windows 7 Pro SP1: Lazarus 2.2.6 (64 bit on VBox)

Hansaplast

  • Hero Member
  • *****
  • Posts: 674
  • Tweaking4All.com
    • Tweaking4All
Re: TUpDown gives bad access
« Reply #4 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?

VTwin

  • Hero Member
  • *****
  • Posts: 1215
  • Former Turbo Pascal 3 user
Re: TUpDown gives bad access
« Reply #5 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.
« Last Edit: May 06, 2019, 07:03:18 pm by VTwin »
“Talk is cheap. Show me the code.” -Linus Torvalds

Free Pascal Compiler 3.2.2
macOS 12.1: Lazarus 2.2.6 (64 bit Cocoa M1)
Ubuntu 18.04.3: Lazarus 2.2.6 (64 bit on VBox)
Windows 7 Pro SP1: Lazarus 2.2.6 (64 bit on VBox)

Hansaplast

  • Hero Member
  • *****
  • Posts: 674
  • Tweaking4All.com
    • Tweaking4All
Re: TUpDown gives bad access
« Reply #6 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.  :)

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: TUpDown gives bad access
« Reply #7 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

Hansaplast

  • Hero Member
  • *****
  • Posts: 674
  • Tweaking4All.com
    • Tweaking4All
Re: TUpDown gives bad access
« Reply #8 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! :)

VTwin

  • Hero Member
  • *****
  • Posts: 1215
  • Former Turbo Pascal 3 user
Re: TUpDown gives bad access
« Reply #9 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. :)
“Talk is cheap. Show me the code.” -Linus Torvalds

Free Pascal Compiler 3.2.2
macOS 12.1: Lazarus 2.2.6 (64 bit Cocoa M1)
Ubuntu 18.04.3: Lazarus 2.2.6 (64 bit on VBox)
Windows 7 Pro SP1: Lazarus 2.2.6 (64 bit on VBox)

 

TinyPortal © 2005-2018