Lazarus

Programming => Widgetset => Cocoa => Topic started by: VTwin on March 04, 2020, 07:36:58 pm

Title: [SOLVED] ColorDialog crashing
Post by: VTwin 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
Title: Re: ColorDialog crashing
Post by: winni on March 04, 2020, 07:40:42 pm
Again Mac?
Title: Re: ColorDialog crashing
Post by: VTwin 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
Title: Re: ColorDialog crashing
Post by: skalogryz 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.
Title: Re: ColorDialog crashing
Post by: skalogryz on March 05, 2020, 02:47:10 am
Please bug report.
too late! please try r62690
Title: Re: ColorDialog crashing
Post by: VTwin on March 05, 2020, 03:24:30 am
Excellent! Trunk t62690 is working. Not yet working on fixes.

Cheers,
VTwin
Title: Re: ColorDialog crashing
Post by: VTwin 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.
Title: Re: ColorDialog crashing
Post by: skalogryz 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.
Title: Re: ColorDialog crashing
Post by: VTwin 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.  :(

 
Title: Re: ColorDialog crashing
Post by: skalogryz 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?
Title: Re: ColorDialog crashing
Post by: VTwin 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.
Title: Re: ColorDialog crashing
Post by: skalogryz 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")
Title: Re: ColorDialog crashing
Post by: VTwin 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.

Title: Re: ColorDialog crashing
Post by: skalogryz 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.
Title: Re: ColorDialog crashing
Post by: skalogryz 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.
Title: Re: ColorDialog crashing
Post by: skalogryz on March 08, 2020, 06:18:44 am
ok, a better solution is found and have been applied to the trunk.

If you still have the the color dialog showing up on start, simply press "Button1" to explicitly request it to show, and after that close the app (the normal way).


At this point, the only outstanding problem is the "grayscale" crash.
Title: Re: ColorDialog crashing
Post by: VTwin on March 08, 2020, 05:26:34 pm
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.

Thanks. I cam confirm that that works. However, if I pick a Grayscale or CYMK color, it still crashes.
Title: Re: ColorDialog crashing
Post by: VTwin on March 08, 2020, 05:27:22 pm
ok, a better solution is found and have been applied to the trunk.

If you still have the the color dialog showing up on start, simply press "Button1" to explicitly request it to show, and after that close the app (the normal way).


At this point, the only outstanding problem is the "grayscale" crash.

I'll give that a shot.
Title: Re: ColorDialog crashing
Post by: VTwin on March 08, 2020, 05:56:56 pm
Wow, excellent! I can not make it crash. Even the Grayscale seems to work now. :)

Although it does not crash, there is something slightly amiss with CMYK. If I select a CMYK color, close the program, and restart it, all the CMYK colors are black.
Title: Re: ColorDialog crashing
Post by: VTwin on April 05, 2020, 06:13:17 pm
Is it possible to move this fix to the fixes branch yet?

Cheers,
VTwin
Title: Re: ColorDialog crashing
Post by: skalogryz on April 06, 2020, 03:21:30 pm
it is now in fixes branch
Title: Re: ColorDialog crashing
Post by: VTwin on April 07, 2020, 02:20:10 am
Excellent! Thank you so much, it is working.

Cheers,
VTWin
TinyPortal © 2005-2018