-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tray: SDL_GetTrayEntries
caller-owned pointer, dark mode support on Windows
#11809
Conversation
a2cc86d
to
fb7d5da
Compare
src/tray/cocoa/SDL_tray.m
Outdated
if (size) { | ||
*size = menu->nEntries; | ||
*size = (int) menu->nEntries; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why isn't nEntries int?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Originally, it was because nEntries couldn't be negative and it avoided casts when mixing it with memory/addressing-related functions. I did expose the size parameters as int in the interface though, so I can change it to int if necessary. (Alternatively, I can change the parameters to be size_t, but I'm not sure if size_t is an acceptable type to have in the API)
fb7d5da
to
a444857
Compare
a444857
to
b511bf6
Compare
Can you separate out the dark mode fix into a separate PR? Thinking more about the memory management of the tray API, we usually return a copy of an array of IDs when the underlying objects can change out from under the user. Displays, joysticks, etc. all fall under this category. Returning a copy of an array of pointers doesn't actually make it any safer, because if the underlying data changes, you're left with a dangling pointer that can crash if you dereference it. I think it's actually safer to just return a const, NULL terminated, array of pointers, like you did before (with the addition of NULL termination). @icculus, am I missing anything here? |
Agreed. Unlike unplugging a USB joystick, these shouldn't change outside of the app doing it itself. |
b511bf6
to
13bfb68
Compare
I've reverted the changes and made a new commit that just adds the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, thanks!
Description
This fixes two issues with the system tray:
SDL_GetTrayEntries
returns a caller-owned pointer (it simply duplicates the internal list).Existing Issue(s)
Fixes #11787