util: disallow destruction of Signal from handler

refs #2313

Change-Id: Ifec8dcfe66873f88b8a39726be68f090b8c18fb3
diff --git a/src/util/signal-signal.hpp b/src/util/signal-signal.hpp
index cb9c0c4..4364d6a 100644
--- a/src/util/signal-signal.hpp
+++ b/src/util/signal-signal.hpp
@@ -56,6 +56,8 @@
 
   Signal();
 
+  ~Signal();
+
   /** \brief connects a handler to the signal
    *  \note If invoked from a handler, the new handler won't receive the current emitted signal.
    *  \warning The handler is permitted to disconnect itself, but it must ensure its validity.
@@ -79,6 +81,7 @@
   /** \brief emits a signal
    *  \param args arguments passed to all handlers
    *  \warning Emitting the signal from a handler is undefined behavior.
+   *  \warning Destructing the Signal object during signal emission is undefined behavior.
    *  \note If a handler throws, the exception will be propagated to the caller
    *        who emits this signal, and some handlers may not be executed.
    */
@@ -161,6 +164,12 @@
 }
 
 template<typename Owner, typename ...TArgs>
+Signal<Owner, TArgs...>::~Signal()
+{
+  BOOST_ASSERT(!m_isExecuting);
+}
+
+template<typename Owner, typename ...TArgs>
 inline Connection
 Signal<Owner, TArgs...>::connect(const Handler& handler)
 {