Browse Source

Merge pull request #2434 from arkpar/az-fix

Prevent handlers being called on shutdown
cl-refactor
Gav Wood 10 years ago
parent
commit
d6bec78cec
  1. 12
      libethcore/Common.h

12
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<HandlerAux> 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>(_args)...); }
void operator()(Args&... _args)
{
for (auto const& f: m_fire)
if (auto h = f.second.lock())
h->fire(std::forward<Args>(_args)...);
}
private:
std::map<unsigned, std::shared_ptr<typename Signal::HandlerAux>> m_fire;
std::map<unsigned, std::weak_ptr<typename Signal::HandlerAux>> m_fire;
};
template<class... Args> using Handler = std::shared_ptr<typename Signal<Args...>::HandlerAux>;

Loading…
Cancel
Save