From 9935b950eee30183d17c44ae822146acc3886915 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Fri, 2 Jan 2009 19:38:43 +0000 Subject: [PATCH] Ports say when they're going away. git-svn-id: svn://localhost/ardour2/branches/3.0@4380 d708f5d6-7413-0410-9779-e7cbd77b26cf --- libs/ardour/ardour/port.h | 7 ++++++- libs/ardour/port.cc | 11 +++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/libs/ardour/ardour/port.h b/libs/ardour/ardour/port.h index ad81d6763f..6bd607c334 100644 --- a/libs/ardour/ardour/port.h +++ b/libs/ardour/ardour/port.h @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -37,7 +38,7 @@ class Buffer; /** Abstract base for ports */ -class Port : public virtual sigc::trackable { +class Port : public virtual PBD::Destructible { public: enum Flags { IsInput = JackPortIsInput, @@ -132,6 +133,10 @@ class Port : public virtual sigc::trackable { std::set _connections; static AudioEngine* engine; + + private: + + void port_going_away (Port *); }; class PortConnectableByName { diff --git a/libs/ardour/port.cc b/libs/ardour/port.cc index 7aadb9183f..f3e0739e83 100644 --- a/libs/ardour/port.cc +++ b/libs/ardour/port.cc @@ -34,6 +34,7 @@ Port::Port (const std::string& name, Flags flgs) Port::~Port () { + drop_references (); disconnect_all (); } @@ -59,6 +60,7 @@ Port::connect (Port& other) result = _connections.insert (&other); if (result.second) { + other.GoingAway.connect (sigc::bind (mem_fun (*this, &Port::port_going_away), &other)); return 0; } else { return 1; @@ -131,6 +133,14 @@ Port::get_connections (vector& names) const return i; } +void +Port::port_going_away (Port* p) +{ + /* caller must hold process lock */ + + disconnect (*p); +} + //------------------------------------- @@ -377,3 +387,4 @@ PortFacade::reset () _ext_port->reset (); } } + -- 2.30.2