From 1d5a25991d9d610d06beac3b53010494160dfd1e Mon Sep 17 00:00:00 2001 From: arkpar Date: Thu, 9 Jul 2015 14:39:35 +0200 Subject: [PATCH] Prevent handles call on shutdown --- libethcore/Common.h | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/libethcore/Common.h b/libethcore/Common.h index fe9692ed3..296f0d01d 100644 --- a/libethcore/Common.h +++ b/libethcore/Common.h @@ -157,7 +157,8 @@ public: ~Signal() { for (auto const& h : m_fire) - h.second->reset(); + if (auto l = h.second.lock()) + l->reset(); } std::shared_ptr add(Callback const& _h) @@ -168,10 +169,15 @@ public: return h; } - void operator()(Args&... _args) { for (auto const& f: m_fire) f.second->fire(std::forward(_args)...); } + void operator()(Args&... _args) + { + for (auto const& f: m_fire) + if (auto h = f.second.lock()) + h->fire(std::forward(_args)...); + } private: - std::map> m_fire; + std::map> m_fire; }; template using Handler = std::shared_ptr::HandlerAux>;