diff options
author | bruvzg <7645683+bruvzg@users.noreply.github.com> | 2023-03-23 13:26:11 +0200 |
---|---|---|
committer | RĂ©mi Verschelde <rverschelde@gmail.com> | 2023-03-30 23:20:20 +0200 |
commit | 50f26811b0409a0b44b1d7df4532c38cafd0a14a (patch) | |
tree | 94fa6ee6701f929a8100f48efe1f995a6f536146 /platform/macos | |
parent | c9ee5080898648f709777a5ffa8d68a73c1e3ad2 (diff) |
[macOS] Fix infinite loop caused by global menu callbacks which trigger EditorProgress dialog.
(cherry picked from commit 48730e3b772931b12b34b33f8f57786d54cdb691)
Diffstat (limited to 'platform/macos')
-rw-r--r-- | platform/macos/display_server_macos.h | 2 | ||||
-rw-r--r-- | platform/macos/display_server_macos.mm | 10 |
2 files changed, 7 insertions, 5 deletions
diff --git a/platform/macos/display_server_macos.h b/platform/macos/display_server_macos.h index fb9bcdfe56..169dd845ed 100644 --- a/platform/macos/display_server_macos.h +++ b/platform/macos/display_server_macos.h @@ -188,7 +188,7 @@ private: Variant tag; Callable callback; }; - Vector<MenuCall> deferred_menu_calls; + List<MenuCall> deferred_menu_calls; const NSMenu *_get_menu_root(const String &p_menu_root) const; NSMenu *_get_menu_root(const String &p_menu_root); diff --git a/platform/macos/display_server_macos.mm b/platform/macos/display_server_macos.mm index af80c1c590..2d0335f95a 100644 --- a/platform/macos/display_server_macos.mm +++ b/platform/macos/display_server_macos.mm @@ -3491,14 +3491,16 @@ void DisplayServerMacOS::process_events() { } // Process "menu_callback"s. - for (MenuCall &E : deferred_menu_calls) { - Variant tag = E.tag; + while (List<MenuCall>::Element *call_p = deferred_menu_calls.front()) { + 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 ret; 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) { _process_key_events(); |