Initialize invalid parent_{tray,entry} to NULL

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.
This commit is contained in:
Semphris
2025-01-16 22:07:57 -05:00
committed by Ryan C. Gordon
parent b79ada6aa5
commit 354d2c390c

View File

@@ -304,6 +304,7 @@ SDL_TrayMenu *SDL_CreateTrayMenu(SDL_Tray *tray)
tray->menu->hMenu = CreatePopupMenu();
tray->menu->parent_tray = tray;
tray->menu->parent_entry = NULL;
return tray->menu;
}
@@ -395,6 +396,8 @@ SDL_TrayEntry *SDL_InsertTrayEntryAt(SDL_TrayMenu *menu, int pos, const char *la
return NULL;
}
SDL_memset((void *) entry, 0, sizeof(*entry));
wchar_t *label_w = NULL;
if (label && (label_w = escape_label(label)) == NULL) {
@@ -417,10 +420,13 @@ SDL_TrayEntry *SDL_InsertTrayEntryAt(SDL_TrayMenu *menu, int pos, const char *la
return NULL;
}
SDL_memset((void *) entry->submenu, 0, sizeof(*entry->submenu));
entry->submenu->hMenu = CreatePopupMenu();
entry->submenu->nEntries = 0;
entry->submenu->entries = NULL;
entry->submenu->parent_entry = entry;
entry->submenu->parent_tray = NULL;
entry->id = (UINT_PTR) entry->submenu->hMenu;
} else {