Skip to content

Commit b563968

Browse files
committed
Fixup CI
1 parent 17ce1d7 commit b563968

File tree

6 files changed

+37
-20
lines changed

6 files changed

+37
-20
lines changed

examples/video/01-menubar/menubar.c

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -51,30 +51,43 @@ static SDL_EventType_MenuExt EVENT_START = (SDL_EventType_MenuExt)0;
5151

5252
void PrintMenuItems(SDL_Renderer* renderer, SDL_MenuItem *menu_item, int indent, int *total_index)
5353
{
54+
SDL_MenuItem *app_menu = NULL;
55+
Sint64 item_count = 0;
56+
Sint64 i = 0;
57+
5458
if (!menu_item) {
5559
return;
5660
}
5761

58-
SDL_MenuItem *app_menu = SDL_GetMenuBarAppMenu(menu_item);
59-
if (app_menu) {
60-
SDL_RenderDebugText(renderer, (float)(8 * indent * 2), (float)(*total_index * 8), " -> AppMenu");
61-
++(*total_index);
62-
}
63-
6462
const char* label = SDL_GetMenuItemLabel(menu_item);
6563

6664
if (!label) {
6765
label = "no label given";
6866
}
6967

7068
SDL_RenderDebugText(renderer, (float)(8 * indent * 2), (float)(*total_index * 8), label);
71-
7269
++(*total_index);
70+
71+
72+
if (SDL_GetMenuItemType(menu_item) == SDL_MENUITEM_MENUBAR) {
73+
app_menu = SDL_GetMenuBarAppMenu(menu_item);
74+
75+
if (app_menu) {
76+
SDL_RenderDebugText(renderer, (float)(8 * (indent + 1) * 2), (float)(*total_index * 8), " -> AppMenu");
77+
++(*total_index);
78+
79+
item_count = SDL_GetMenuChildItems(app_menu);
80+
81+
for (i = 0; i < item_count; ++i) {
82+
PrintMenuItems(renderer, SDL_GetMenuChildItem(app_menu, (size_t)i), indent + 2, total_index);
83+
}
84+
}
85+
}
7386

74-
size_t item_count = SDL_GetMenuChildItems(menu_item);
87+
item_count = SDL_GetMenuChildItems(menu_item);
7588

76-
for (size_t i = 0; i < item_count; ++i) {
77-
PrintMenuItems(renderer, SDL_GetMenuChildItem(menu_item, i), indent + 1, total_index);
89+
for (i = 0; i < item_count; ++i) {
90+
PrintMenuItems(renderer, SDL_GetMenuChildItem(menu_item, (size_t)i), indent + 1, total_index);
7891
}
7992
}
8093

@@ -114,10 +127,10 @@ void CreateMenuBar_1()
114127

115128
SDL_MenuItem* app_menu = SDL_GetMenuBarAppMenu(menu_bar_1);
116129
if (app_menu) {
117-
SDL_assert(!SDL_CreateMenuItem(menu_bar_1, "Exit", SDL_MENUITEM_BUTTON, MENU_BAR_EXIT));
118-
SDL_CreateMenuItem(app_menu, "Exit", SDL_MENUITEM_BUTTON, MENU_BAR_EXIT);
130+
SDL_assert(!SDL_CreateMenuItem(menu_bar_1, "Exit 1", SDL_MENUITEM_BUTTON, MENU_BAR_EXIT));
131+
SDL_CreateMenuItem(app_menu, "Exit 1", SDL_MENUITEM_BUTTON, MENU_BAR_EXIT);
119132
} else {
120-
SDL_CreateMenuItem(menu_bar_1, "Exit", SDL_MENUITEM_BUTTON, MENU_BAR_EXIT);
133+
SDL_CreateMenuItem(menu_bar_1, "Exit 1", SDL_MENUITEM_BUTTON, MENU_BAR_EXIT);
121134
}
122135
}
123136

@@ -161,10 +174,10 @@ void CreateMenuBar_2()
161174

162175
SDL_MenuItem* app_menu = SDL_GetMenuBarAppMenu(menu_bar_2);
163176
if (app_menu) {
164-
SDL_assert(!SDL_CreateMenuItem(menu_bar_2, "Exit", SDL_MENUITEM_BUTTON, MENU_BAR_EXIT));
165-
SDL_CreateMenuItem(app_menu, "Exit", SDL_MENUITEM_BUTTON, MENU_BAR_EXIT);
177+
SDL_assert(!SDL_CreateMenuItem(menu_bar_2, "Exit 2", SDL_MENUITEM_BUTTON, MENU_BAR_EXIT));
178+
SDL_CreateMenuItem(app_menu, "Exit 2", SDL_MENUITEM_BUTTON, MENU_BAR_EXIT);
166179
} else {
167-
SDL_CreateMenuItem(menu_bar_2, "Exit", SDL_MENUITEM_BUTTON, MENU_BAR_EXIT);
180+
SDL_CreateMenuItem(menu_bar_2, "Exit 2", SDL_MENUITEM_BUTTON, MENU_BAR_EXIT);
168181
}
169182
}
170183

include/SDL3/SDL_video.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3150,7 +3150,7 @@ extern SDL_DECLSPEC SDL_MenuItem *SDL_CreateMenuItem(SDL_MenuItem *menu_as_item,
31503150
/**
31513151
* Gets the number of children of the given menu, must be SDL_MENUITEM_MENUBAR or SDL_MENUITEM_SUBMENU
31523152
*
3153-
* \param menu_item the menu item to get the label of.
3153+
* \param menu_as_item the menu item to get the label of.
31543154
* \returns the number of children of the given menu, or -1 on failure; call SDL_GetError() for more
31553155
* information.
31563156
*

src/dynapi/SDL_dynapi.sym

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1272,7 +1272,6 @@ SDL3_0.0.0 {
12721272
SDL_CreateMenuItem;
12731273
SDL_GetMenuChildItems;
12741274
SDL_GetMenuChildItem;
1275-
SDL_GetMenuItemLabel;
12761275
SDL_GetMenuItemType;
12771276
SDL_SetMenuItemLabel;
12781277
SDL_SetMenuItemChecked;

src/video/SDL_video.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6332,9 +6332,15 @@ SDL_MenuItem *SDL_CreateMenuItem(SDL_MenuItem *menu_bar_as_item, const char *lab
63326332
SDL_MenuItem *SDL_GetMenuBarAppMenu(SDL_MenuItem *menu_bar)
63336333
{
63346334
CHECK_MENUITEM_MAGIC(menu_bar, NULL);
6335+
6336+
if (menu_bar->common.type != SDL_MENUITEM_MENUBAR) {
6337+
SDL_SetError("menu_bar must be a SDL_MENUITEM_MENUBAR.");
6338+
return NULL;
6339+
}
63356340

63366341
if (!menu_bar->menu_bar.app_menu) {
63376342
SDL_SetError("This platform doesn't support an Application menu.");
6343+
return NULL;
63386344
}
63396345

63406346
return menu_bar->menu_bar.app_menu;

src/video/cocoa/SDL_cocoavideo.m

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -390,8 +390,6 @@ bool Cocoa_SetWindowMenuBar(SDL_Window *window, SDL_MenuBar *menu_bar)
390390
return true;
391391
}
392392

393-
// If we don't set it to nil first, it won't change menu bars until you switch off and back on focus.
394-
[NSApp setMainMenu:nil];
395393
PlatformMenuData* platform_data = (__bridge PlatformMenuData*)menu_bar->common.item_common.platform_data;
396394
[NSApp setMainMenu:platform_data->menu];
397395

src/video/windows/SDL_windowsevents.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2442,6 +2442,7 @@ LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara
24422442
event.menu.windowID = data->window->id;
24432443

24442444
SDL_PushEvent(&event);
2445+
break;
24452446
}
24462447

24472448
#endif // !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES)

0 commit comments

Comments
 (0)