From 6a96bcf1659d07cd3a7f7e65519007abfaeda2a0 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Sat, 15 Jul 2017 11:59:10 +0200 Subject: Ensure that the Notifier call order is the same as the connection order. --- src/notifier.h | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'src/notifier.h') diff --git a/src/notifier.h b/src/notifier.h index ff59741..f044d98 100644 --- a/src/notifier.h +++ b/src/notifier.h @@ -27,10 +27,9 @@ #pragma once #include -#include -#include +#include +#include #include -#include namespace aux { @@ -124,7 +123,7 @@ public: template void connect(O* p, const F& fn) { - slots[p] = std::move(construct_mem_fn(fn, p, aux::gen_int_sequence{})); + slots.emplace_back(std::make_pair(p, std::move(construct_mem_fn(fn, p, aux::gen_int_sequence{})))); if(p && dynamic_cast(p)) { dynamic_cast(p)->registerNotifier(this); @@ -134,7 +133,14 @@ public: //! \brief Disconnect object from this Notifier. void disconnect(Listener* object) { - slots.erase(object); + for(auto it = slots.begin(); it != slots.end(); ++it) + { + if(it->first == object) + { + slots.erase(it); + return; + } + } } //! \brief Activate this notifier by pretending it is a function. @@ -148,7 +154,7 @@ public: } private: - std::map slots; + std::list> slots; template callback_type construct_mem_fn(const F& fn, O* p, aux::int_sequence) const -- cgit v1.2.3