Core/Signal: Fix disconnection while iterating

This is no longer an issue, you can now disconnect every signal as you
wish even while the iteration


Former-commit-id: 5caadaa860c62ce09f02f7555aa7c6adebc74fb9
This commit is contained in:
Lynix
2015-06-08 00:28:51 +02:00
parent ec9876011f
commit 5ce3c5a0cb
2 changed files with 41 additions and 8 deletions

View File

@@ -26,7 +26,7 @@ class NzSignal
class Connection;
class ConnectionGuard;
NzSignal() = default;
NzSignal();
NzSignal(const NzSignal&) = delete;
NzSignal(NzSignal&& signal);
~NzSignal() = default;
@@ -50,6 +50,7 @@ class NzSignal
using SlotPtr = std::shared_ptr<Slot>;
using SlotList = std::vector<SlotPtr>;
using SlotListIndex = typename SlotList::size_type;
struct Slot
{
@@ -60,12 +61,13 @@ class NzSignal
Callback callback;
NzSignal* signal;
typename SlotList::size_type index;
SlotListIndex index;
};
void Disconnect(const SlotPtr& slot);
SlotList m_slots;
mutable SlotListIndex m_slotIterator;
};
template<typename... Args>