summaryrefslogtreecommitdiff
path: root/libs/pbd/pbd
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2016-12-15 16:36:39 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2016-12-15 16:36:50 +0000
commit529b91828db699d9605a424f17b701fa907178c2 (patch)
treead488c97833327ed3f19c07b8be71a1989a8ac14 /libs/pbd/pbd
parent342c112ae3ccbcad9db2eac1bd9959962c427226 (diff)
store InvalidationRecord in a Connection object and ref/unref it as appropriate
Diffstat (limited to 'libs/pbd/pbd')
-rw-r--r--libs/pbd/pbd/signals.h18
-rw-r--r--libs/pbd/pbd/signals.py25
2 files changed, 31 insertions, 12 deletions
diff --git a/libs/pbd/pbd/signals.h b/libs/pbd/pbd/signals.h
index 42727b7adc..df4c9cef29 100644
--- a/libs/pbd/pbd/signals.h
+++ b/libs/pbd/pbd/signals.h
@@ -78,7 +78,12 @@ protected:
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 ()
{
@@ -89,15 +94,26 @@ public:
}
}
+ 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>
diff --git a/libs/pbd/pbd/signals.py b/libs/pbd/pbd/signals.py
index fbcf1d4016..67589a1f66 100644
--- a/libs/pbd/pbd/signals.py
+++ b/libs/pbd/pbd/signals.py
@@ -139,7 +139,7 @@ def signal(f, n, v):
*/
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.
@@ -150,7 +150,7 @@ def signal(f, n, v):
*/
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
@@ -196,7 +196,7 @@ def signal(f, n, v):
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("""
}
@@ -215,7 +215,7 @@ def signal(f, n, v):
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("""
@@ -290,9 +290,9 @@ def signal(f, n, v):
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
@@ -307,13 +307,16 @@ def signal(f, n, v):
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
}
};