[Utils] Copy signal slots before executing

This commit is contained in:
momo5502 2017-01-21 01:52:30 +01:00
parent 82e9f3864c
commit 0f258046c3
2 changed files with 9 additions and 6 deletions

View File

@ -17,16 +17,16 @@ namespace Components
pushad pushad
call Renderer::FrameHandler call Renderer::FrameHandler
popad popad
jmp Renderer::DrawFrameHook.original jmp Renderer::DrawFrameHook.original
} }
} }
void Renderer::FrameHandler() void Renderer::FrameHandler()
{ {
auto copy = Renderer::FrameSignal; Renderer::FrameSignal();
copy();
copy = Renderer::FrameOnceSignal; auto copy = Renderer::FrameOnceSignal;
Renderer::FrameOnceSignal.clear(); Renderer::FrameOnceSignal.clear();
copy(); copy();
} }

View File

@ -34,18 +34,21 @@ namespace Utils
public: public:
void connect(Slot<T> slot) void connect(Slot<T> slot)
{ {
slots.push_back(slot); this->slots.push_back(slot);
} }
void clear() void clear()
{ {
slots.clear(); this->slots.clear();
} }
template <class ...Args> template <class ...Args>
void operator()(Args&&... args) const void operator()(Args&&... args) const
{ {
for (auto& slot : slots) std::vector<Slot<T>> copiedSlots;
Utils::Merge(&copiedSlots, this->slots);
for (auto slot : copiedSlots)
{ {
slot(std::forward<Args>(args)...); slot(std::forward<Args>(args)...);
} }