From 78427bc45ac5896988fe9d8579cd1e395bd2439f Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Fri, 12 Aug 2011 00:26:56 +1000 Subject: [PATCH] Reorder signal exec traversal to allow deletions --- signal.hpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/signal.hpp b/signal.hpp index d7d8c120..8aa19785 100644 --- a/signal.hpp +++ b/signal.hpp @@ -103,8 +103,11 @@ namespace util { /// Execute all callbacks, ignoring the return parameters. Does not combine results. void operator () (Args... tail) { - for (auto i = m_children.cbegin (); i != m_children.cend (); ++i) - (*i)(tail...); + for (auto i = m_children.cbegin (); i != m_children.cend (); ) { + // Increment before we execute so that the caller is able to deregister during execution. + auto current = i++; + (*current)(tail...); + } } }; }