From 0f258046c320b53340e60bdb6c9781659de4439a Mon Sep 17 00:00:00 2001 From: momo5502 Date: Sat, 21 Jan 2017 01:52:30 +0100 Subject: [PATCH] [Utils] Copy signal slots before executing --- src/Components/Modules/Renderer.cpp | 6 +++--- src/Utils/Utils.hpp | 9 ++++++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/Components/Modules/Renderer.cpp b/src/Components/Modules/Renderer.cpp index 7c6e1851..f5e771d6 100644 --- a/src/Components/Modules/Renderer.cpp +++ b/src/Components/Modules/Renderer.cpp @@ -17,16 +17,16 @@ namespace Components pushad call Renderer::FrameHandler popad + jmp Renderer::DrawFrameHook.original } } void Renderer::FrameHandler() { - auto copy = Renderer::FrameSignal; - copy(); + Renderer::FrameSignal(); - copy = Renderer::FrameOnceSignal; + auto copy = Renderer::FrameOnceSignal; Renderer::FrameOnceSignal.clear(); copy(); } diff --git a/src/Utils/Utils.hpp b/src/Utils/Utils.hpp index 87843e45..14233450 100644 --- a/src/Utils/Utils.hpp +++ b/src/Utils/Utils.hpp @@ -34,18 +34,21 @@ namespace Utils public: void connect(Slot slot) { - slots.push_back(slot); + this->slots.push_back(slot); } void clear() { - slots.clear(); + this->slots.clear(); } template void operator()(Args&&... args) const { - for (auto& slot : slots) + std::vector> copiedSlots; + Utils::Merge(&copiedSlots, this->slots); + + for (auto slot : copiedSlots) { slot(std::forward(args)...); }