diff --git a/libs/pbd/pbd/signal.h.py b/libs/pbd/pbd/signal.h.py index 70a1a2d88c..9997811c52 100644 --- a/libs/pbd/pbd/signal.h.py +++ b/libs/pbd/pbd/signal.h.py @@ -9,10 +9,7 @@ if len(sys.argv) < 2: f = open(sys.argv[1], 'w') print >>f,""" -/** THIS FILE IS AUTOGENERATED: DO NOT EDIT. - * - * This file is generated by signals.h.py. - */ +/** THIS FILE IS AUTOGENERATED by signals.h.py: CHANGES WILL BE LOST */ #include #include @@ -26,7 +23,7 @@ namespace PBD { class Connection; -class SignalBase : public boost::enable_shared_from_this +class SignalBase { public: virtual ~SignalBase () {} @@ -39,17 +36,25 @@ protected: class Connection : public boost::enable_shared_from_this { public: - Connection (boost::shared_ptr b) : _signal (b) {} + Connection (SignalBase* b) : _signal (b) {} void disconnect () { + boost::mutex::scoped_lock lm (_mutex); if (_signal) { _signal->disconnect (shared_from_this ()); } } + void signal_going_away () + { + boost::mutex::scoped_lock lm (_mutex); + _signal = 0; + } + private: - boost::shared_ptr _signal; + boost::mutex _mutex; + SignalBase* _signal; }; template @@ -112,10 +117,23 @@ def simple_signal(f, n, v): print >>f,"public:" print >>f,"" + print >>f,"\t~SimpleSignal%d ()" % n + print >>f,""" + { + boost::mutex::scoped_lock lm (_mutex); +#if __GNUC__ > 4 || (__GNUC__ == 4 && (__GNUC_MINOR__ >= 6)) + for (typename Slots::iterator i = _slots.begin(); i != _slots.end(); ++i) { +#else + for (Slots::iterator i = _slots.begin(); i != _slots.end(); ++i) { +#endif + i->first->signal_going_away (); + } + } + boost::shared_ptr connect (slot_function_type f) { - boost::shared_ptr c (new Connection (shared_from_this ())); + boost::shared_ptr c (new Connection (this)); boost::mutex::scoped_lock lm (_mutex); _slots[c] = f; return c;