Reorder signal exec traversal to allow deletions

This commit is contained in:
Danny Robson 2011-08-12 00:26:56 +10:00
parent 955b97c73e
commit 78427bc45a

View File

@ -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...);
}
}
};
}