Merge pull request #83243 from bruvzg/macos_sys_def_menu_items

[macOS] Fix crash when using system default menu shortcuts.
This commit is contained in:
Rémi Verschelde 2023-10-13 11:47:31 +02:00
commit 577fbd8841
No known key found for this signature in database
GPG Key ID: C3336907360768E1
2 changed files with 15 additions and 13 deletions

View File

@ -649,7 +649,7 @@ void DisplayServerMacOS::menu_callback(id p_sender) {
}
}
if (value->callback != Callable()) {
if (value->callback.is_valid()) {
MenuCall mc;
mc.tag = value->meta;
mc.callback = value->callback;

View File

@ -56,7 +56,7 @@
- (void)menu:(NSMenu *)menu willHighlightItem:(NSMenuItem *)item {
if (item) {
GodotMenuItem *value = [item representedObject];
if (value && value->hover_callback != Callable()) {
if (value && value->hover_callback.is_valid()) {
// If custom callback is set, use it.
value->hover_callback.call(value->meta);
}
@ -73,7 +73,8 @@
if (ev_modifiers == item_modifiers) {
GodotMenuItem *value = [menu_item representedObject];
if (value->key_callback != Callable()) {
if (value) {
if (value->key_callback.is_valid()) {
// If custom callback is set, use it.
value->key_callback.call(value->meta);
} else {
@ -86,6 +87,7 @@
// Suppress default menu action.
*target = self;
*action = @selector(doNothing:);
}
return YES;
}
}