Color.SelectedFromDialog Reproducibly Crashing on macOS 11.3

Feedback Case Number: 64743.

This seems like a pretty serious bug for Mac users. I’m running Big Sur 11.3 on Apple Silicon.

Color.SelectedFromDialog reliably crashes any Xojo app when used as described in the Xojo docs.

Put this code in the action event of a button:

Var c As Color = Color.Red
Call Color.SelectedFromDialog(c, "Choose Colour")

Click the button and choose a colour. Then close the picker window using the red close button. The app will crash with the debugger complaining about a NilObjectException on the Call line. The variable c is not Nil according to the debugger. No idea what is being set to Nil but the app will crash every single time.

As far as I can see, I have no way of selecting a colour on macOS 11.3.

Big bug.

Morning @GarryPettet,

I think you have to use the “new” DesktopColorPicker introduced in Xojo 2021r1.1 to prevent this exception. I imagine this was the reason for this new control.

I seemed to have entirely missed that new control. Thanks for pointing it out @Martin_T.

Hopefully that’ll sort out my issue without having to hack my app too much…

1 Like

This might be a solution on MacOS as it seems we get a NilObjectException but it’s working fine if that’s ignored.

Var SelectedColor As Color = &cFF0000 // Default red
Var SelectionChanged As Boolean

#Pragma BreakOnExceptions False
Try 
  SelectionChanged = Color.SelectedFromDialog(SelectedColor, "Profile Color")
Catch e As NilObjectException
  // We just ignore the NOE since it's still working...;)
Finally
  
  If SelectionChanged Then
    Self.Profile.ProfileColor = SelectedColor
    me.FillColor = SelectedColor
  End If
  
End Try
#Pragma BreakOnExceptions Default
Forum for Xojo Programming Language and IDE. Copyright © 2021 Xojo, Inc.