From 1f7d50a9b9140d02f6a9afb97734eb9761b6a0d4 Mon Sep 17 00:00:00 2001 From: camila314 <47485054+camila314@users.noreply.github.com> Date: Tue, 7 Feb 2023 13:58:21 -0600 Subject: [PATCH] fix potentially modifying event listeners set while iterating --- loader/src/loader/Event.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/loader/src/loader/Event.cpp b/loader/src/loader/Event.cpp index 87c97e3b..133263b2 100644 --- a/loader/src/loader/Event.cpp +++ b/loader/src/loader/Event.cpp @@ -19,7 +19,9 @@ Event::~Event() {} void Event::postFrom(Mod* m) { if (m) this->sender = m; - for (auto h : Event::listeners()) { + std::unordered_set listeners_copy = Event::listeners(); + + for (auto h : listeners_copy) { if (h->passThrough(this) == ListenerResult::Stop) { break; }