Skip to content
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

Windows trays: Fix fetching parent entry from submenu, allow enabling and disabling entries that aren't checkboxes #12003

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Semphriss
Copy link
Contributor

Description

The test/testtray program would crash on Windows when adding any item and then removing it, because a submenu's parent_entry field was not set.

Additionally, I noticed that some extraneous code copied from the {G,S}etTrayEntryChecked made {G,S}etTrayEntryEnabled work only for checkboxes, which is not the desired behavior.

Both issues were fixed in this commit.


Relatedly, it may be worth to take some time before the first full release to exhaustively test trays and dialogs on all platforms. I did some summary testing on Windows, but I can write extensive unit tests that can quickly be run on all platforms, so that we won't need to manually try every possible combination to find embarrassing mistakes like these two.

Existing Issue(s)

Fixes #12002

Semphris added 2 commits January 16, 2025 21:51
The test/testtray program would crash on Windows when adding any item and then removing it, because a submenu's parent_entry field was not set.

Additionally, I noticed that some extraneous code copied from the {G,S}etTrayEntryChecked made {G,S}etTrayEntryEnabled work only for checkboxes, which is not the desired behavior.

Both issues were fixed in this commit.
The API states that the related functions must return NULL if the function
called (get the parent tray, or get the parent entry) is invalid for this
menu. Initialising the fields to NULL makes that API correct for Windows.
@Semphriss
Copy link
Contributor Author

I've pushed a new commit so that SDL_GetTrayMenuParent{Tray,Entry} would return NULL if the given menu is a submenu or a root menu, respectively, as stated in their documentation. Previously, they would be left uninitialized, therefore filled with 0xbaadf00dbaadf00d on Windows, which would be directly returned by the API functions. The other platforms needed no adjustment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

testtray: removing a tray item makes the test executable crash
1 participant