[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
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();
}

View File

@ -34,18 +34,21 @@ namespace Utils
public:
void connect(Slot<T> slot)
{
slots.push_back(slot);
this->slots.push_back(slot);
}
void clear()
{
slots.clear();
this->slots.clear();
}
template <class ...Args>
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)...);
}