You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-09 12:50:35 +00:00
Prevent pending input event callbacks from erasing the window in the middle of a loop.
This commit is contained in:
@@ -4227,13 +4227,17 @@ void DisplayServerX11::_dispatch_input_event(const Ref<InputEvent> &p_event) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Send to all windows.
|
// Send to all windows. Copy all pending callbacks, since callback can erase window.
|
||||||
|
Vector<Callable> cbs;
|
||||||
for (KeyValue<WindowID, WindowData> &E : windows) {
|
for (KeyValue<WindowID, WindowData> &E : windows) {
|
||||||
Callable callable = E.value.input_event_callback;
|
Callable callable = E.value.input_event_callback;
|
||||||
if (callable.is_valid()) {
|
if (callable.is_valid()) {
|
||||||
callable.call(p_event);
|
cbs.push_back(callable);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for (const Callable &cb : cbs) {
|
||||||
|
cb.call(p_event);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -411,13 +411,17 @@ void DisplayServerMacOS::_dispatch_input_event(const Ref<InputEvent> &p_event) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Send to all windows.
|
// Send to all windows. Copy all pending callbacks, since callback can erase window.
|
||||||
|
Vector<Callable> cbs;
|
||||||
for (KeyValue<WindowID, WindowData> &E : windows) {
|
for (KeyValue<WindowID, WindowData> &E : windows) {
|
||||||
Callable callable = E.value.input_event_callback;
|
Callable callable = E.value.input_event_callback;
|
||||||
if (callable.is_valid()) {
|
if (callable.is_valid()) {
|
||||||
callable.call(p_event);
|
cbs.push_back(callable);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for (const Callable &cb : cbs) {
|
||||||
|
cb.call(p_event);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
in_dispatch_input_event = false;
|
in_dispatch_input_event = false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4253,13 +4253,17 @@ void DisplayServerWindows::_dispatch_input_event(const Ref<InputEvent> &p_event)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Send to all windows.
|
// Send to all windows. Copy all pending callbacks, since callback can erase window.
|
||||||
for (const KeyValue<WindowID, WindowData> &E : windows) {
|
Vector<Callable> cbs;
|
||||||
const Callable callable = E.value.input_event_callback;
|
for (KeyValue<WindowID, WindowData> &E : windows) {
|
||||||
|
Callable callable = E.value.input_event_callback;
|
||||||
if (callable.is_valid()) {
|
if (callable.is_valid()) {
|
||||||
callable.call(p_event);
|
cbs.push_back(callable);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for (const Callable &cb : cbs) {
|
||||||
|
cb.call(p_event);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
in_dispatch_input_event = false;
|
in_dispatch_input_event = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user