class LIBPBD_API Connection : public boost::enable_shared_from_this<Connection>
{
public:
- Connection (SignalBase* b) : _signal (b) {}
+ Connection (SignalBase* b, PBD::EventLoop::InvalidationRecord* ir) : _signal (b), _invalidation_record (ir)
+ {
+ if (_invalidation_record) {
+ _invalidation_record->ref ();
+ }
+ }
void disconnect ()
{
}
}
+ void disconnected ()
+ {
+ if (_invalidation_record) {
+ _invalidation_record->unref ();
+ }
+ }
+
void signal_going_away ()
{
Glib::Threads::Mutex::Lock lm (_mutex);
+ if (_invalidation_record) {
+ _invalidation_record->unref ();
+ }
_signal = 0;
}
private:
Glib::Threads::Mutex _mutex;
SignalBase* _signal;
+ PBD::EventLoop::InvalidationRecord* _invalidation_record;
};
template<typename R>
*/
void connect_same_thread (ScopedConnection& c, const slot_function_type& slot) {
- c = _connect (slot);
+ c = _connect (0, slot);
}
/** Arrange for @a slot to be executed whenever this signal is emitted.
*/
void connect_same_thread (ScopedConnectionList& clist, const slot_function_type& slot) {
- clist.add_connection (_connect (slot));
+ clist.add_connection (_connect (0, slot));
}
/** Arrange for @a slot to be executed in the context of @a event_loop
else:
p = ", %s" % comma_separated(u)
- print("\t\tclist.add_connection (_connect (boost::bind (&compositor, slot, event_loop, ir%s)));" % p, file=f)
+ print("\t\tclist.add_connection (_connect (ir, boost::bind (&compositor, slot, event_loop, ir%s)));" % p, file=f)
print("""
}
ir->event_loop = event_loop;
}
""", file=f)
- print("\t\tc = _connect (boost::bind (&compositor, slot, event_loop, ir%s));" % p, file=f)
+ print("\t\tc = _connect (ir, boost::bind (&compositor, slot, event_loop, ir%s));" % p, file=f)
print("\t}", file=f)
print("""
print("\tfriend class Connection;", file=f)
print("""
- boost::shared_ptr<Connection> _connect (slot_function_type f)
+ boost::shared_ptr<Connection> _connect (PBD::EventLoop::InvalidationRecord* ir, slot_function_type f)
{
- boost::shared_ptr<Connection> c (new Connection (this));
+ boost::shared_ptr<Connection> c (new Connection (this, ir));
Glib::Threads::Mutex::Lock lm (_mutex);
_slots[c] = f;
#ifdef DEBUG_PBD_SIGNAL_CONNECTIONS
print("""
void disconnect (boost::shared_ptr<Connection> c)
{
- Glib::Threads::Mutex::Lock lm (_mutex);
- _slots.erase (c);
+ {
+ Glib::Threads::Mutex::Lock lm (_mutex);
+ _slots.erase (c);
+ }
+ c->disconnected ();
#ifdef DEBUG_PBD_SIGNAL_CONNECTIONS
- if (_debug_connection) {
- std::cerr << "------- DISCCONNECT " << this << " size now " << _slots.size() << std::endl;
+ if (_debug_connection) {
+ std::cerr << "------- DISCCONNECT " << this << " size now " << _slots.size() << std::endl;
PBD::stacktrace (std::cerr, 10);
- }
+ }
#endif
}
};