[macOS] Fix infinite loop caused by global menu callbacks which trigger EditorProgress dialog.

This commit is contained in:
bruvzg 2023-03-23 13:26:11 +02:00
parent 0291fcd7b6
commit 48730e3b77
No known key found for this signature in database
GPG Key ID: 7960FCF39844EC38
2 changed files with 7 additions and 5 deletions

View File

@ -188,7 +188,7 @@ private:
Variant tag; Variant tag;
Callable callback; Callable callback;
}; };
Vector<MenuCall> deferred_menu_calls; List<MenuCall> deferred_menu_calls;
const NSMenu *_get_menu_root(const String &p_menu_root) const; const NSMenu *_get_menu_root(const String &p_menu_root) const;
NSMenu *_get_menu_root(const String &p_menu_root); NSMenu *_get_menu_root(const String &p_menu_root);

View File

@ -3521,14 +3521,16 @@ void DisplayServerMacOS::process_events() {
} }
// Process "menu_callback"s. // Process "menu_callback"s.
for (MenuCall &E : deferred_menu_calls) { while (List<MenuCall>::Element *call_p = deferred_menu_calls.front()) {
Variant tag = E.tag; MenuCall call = call_p->get();
deferred_menu_calls.pop_front(); // Remove before call to avoid infinite loop in case callback is using `process_events` (e.g. EditorProgress).
Variant tag = call.tag;
Variant *tagp = &tag; Variant *tagp = &tag;
Variant ret; Variant ret;
Callable::CallError ce; Callable::CallError ce;
E.callback.callp((const Variant **)&tagp, 1, ret, ce); call.callback.callp((const Variant **)&tagp, 1, ret, ce);
} }
deferred_menu_calls.clear();
if (!drop_events) { if (!drop_events) {
_process_key_events(); _process_key_events();