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>;