Recent

Author Topic: [SOLVED] ColorDialog crashing  (Read 4199 times)

VTwin

  • Hero Member
  • *****
  • Posts: 1215
  • Former Turbo Pascal 3 user
[SOLVED] ColorDialog crashing
« on: March 04, 2020, 07:36:58 pm »
TColorDialog is crashing when I try to select a color from the CMYK or Grayscale palettes. RBG and other palettes are fine. It occurs in the IDE with or without debugging, and in a compiled application.

An example is attached. Can anyone confirm?

VTwin
« Last Edit: April 07, 2020, 02:21:25 am 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)

winni

  • Hero Member
  • *****
  • Posts: 3197
Re: ColorDialog crashing
« Reply #1 on: March 04, 2020, 07:40:42 pm »
Again Mac?

VTwin

  • Hero Member
  • *****
  • Posts: 1215
  • Former Turbo Pascal 3 user
Re: ColorDialog crashing
« Reply #2 on: March 04, 2020, 07:49:36 pm »
Yup :)

    Lazarus »
    Forum »
    Programming »
    Widgetset »
    Cocoa »
    ColorDialog crashing

I am not able to make it crash on Windows or Linux.

Cheers,
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)

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: ColorDialog crashing
« Reply #3 on: March 04, 2020, 10:20:06 pm »
TColorDialog is crashing when I try to select a color from the CMYK or Grayscale palettes. RBG and other palettes are fine. It occurs in the IDE with or without debugging, and in a compiled application.

An example is attached. Can anyone confirm?
Cannot confirm (hasn't tried), but I suspect that the code that should take care of colorschema conversion doesn't work.  I saw crashes related to that.
Please bug report.

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: ColorDialog crashing
« Reply #4 on: March 05, 2020, 02:47:10 am »
Please bug report.
too late! please try r62690

VTwin

  • Hero Member
  • *****
  • Posts: 1215
  • Former Turbo Pascal 3 user
Re: ColorDialog crashing
« Reply #5 on: March 05, 2020, 03:24:30 am »
Excellent! Trunk t62690 is working. Not yet working on fixes.

Cheers,
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)

VTwin

  • Hero Member
  • *****
  • Posts: 1215
  • Former Turbo Pascal 3 user
Re: ColorDialog crashing
« Reply #6 on: March 05, 2020, 03:29:24 am »
Actually something a little weird is still going on. If I run it, pick a color, close, and run it again, the ColorDialog is displayed on startup.

I'm having a little trouble getting a reproducible result. Maybe it is fixed, I'll keep testing.
« Last Edit: March 05, 2020, 03:38:19 am 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)

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: ColorDialog crashing
« Reply #7 on: March 05, 2020, 04:25:53 am »
Actually something a little weird is still going on. If I run it, pick a color, close, and run it again, the ColorDialog is displayed on startup.
that's macOS general UI concept of how "dialogs" (font or color are used).
Those are more of an "application property" and their status is maintained between application launches.
(I think it's also similar for Open/Save dialogs for windows, where the last "opened path" for an app is also maintained by the system).

From LCL point of view, such behavior needs to be replaced, with a cross-platform "show color dialog on demand only"

You might note that after "run again" the color dialog is a little bit different - it doesn't have "Pick" and "Cancel" buttons. And also it's no longer modal.
« Last Edit: March 05, 2020, 04:31:20 am by skalogryz »

VTwin

  • Hero Member
  • *****
  • Posts: 1215
  • Former Turbo Pascal 3 user
Re: ColorDialog crashing
« Reply #8 on: March 06, 2020, 08:01:00 pm »
Thanks. Yes that is what happens, it is displayed non-modal without Pick or Cancel buttons.

However, I was unable to make it not show when restarting the program. I also tried creating it in code, and the same thing occurs. This seems like a bug.

Finally, I set a ColorDialog as a field, creating it in FormCreate. This makes it work as expected, and it is only displayed when requested. See attached. Interestingly, macOS does remember its location between restarts.

BUT, now it crashes again when picking Grayscale or CMKY colors.  :(

 
« Last Edit: March 06, 2020, 08:05:17 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)

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: ColorDialog crashing
« Reply #9 on: March 06, 2020, 09:07:54 pm »
BUT, now it crashes again when picking Grayscale or CMKY colors.  :(
this is odd. I'm away from mac, so I can't check myself. Do you know what's the error message?

VTwin

  • Hero Member
  • *****
  • Posts: 1215
  • Former Turbo Pascal 3 user
Re: ColorDialog crashing
« Reply #10 on: March 07, 2020, 12:23:20 am »
Now the ColorDialog is visible again on startup!!

Selecting a Grayscale color with debugger options off:

"Project project1 raised exception class 'Debugger stopped with reason: EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode 0x0).' At address 938922B"

If I 'Run Without Debugging' I get:

"project1 quit unexpectedly."

Selecting a color with RGP Sliders or Crayons works fine.
“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)

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: ColorDialog crashing
« Reply #11 on: March 08, 2020, 02:28:16 am »
Selecting a Grayscale color with debugger options off:

"Project project1 raised exception class 'Debugger stopped with reason: EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode 0x0).' At address 938922B"
I cannot replicate that. What's the backtrace of the crash?

I appears that the color dialog is being shown on the start only after the app crashes.
I wonder if this is macOS functionality related to "restore after crash" ("restore after system restart")

VTwin

  • Hero Member
  • *****
  • Posts: 1215
  • Former Turbo Pascal 3 user
Re: ColorDialog crashing
« Reply #12 on: March 08, 2020, 03:22:29 am »
It may be that the dialog only reappears after a crash, but running it again without crashing does not fix the problem. At this point I can not stop it from reappearing.

It may take me some time to generate a backtrace, it is something I have done only once or twice before.

Can any other users replicate the problem? Additional input would be appreciated.

“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)

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: ColorDialog crashing
« Reply #13 on: March 08, 2020, 04:07:36 am »
hm... this is what I did.
- run the application from Terminal.
if color box appears - close it.
then terminate the application using Ctrl+C in terminal.

- run the application from Terminal again.
if color box appears - close it and terminate the app again.

- run the application from Terminal again... the color box should not appear.

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: ColorDialog crashing
« Reply #14 on: March 08, 2020, 05:20:42 am »
i've created an issue record to address the restoring of the crashed Color Panel

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

The issue has a patch that would address the problem, by closing the Cocoa generated panel.
I really don't like the solution, yet it works.

 

TinyPortal © 2005-2018