From ab58c894d391086dfdb1762408cc6c1fa9b2383e Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Wed, 25 Dec 2019 17:59:38 +0100 Subject: Use weak-ptr for source added/removed signals (1/2) This might fix a "SessionHandleRef exists across session deletion", when the shared_ptr was be pushed onto a x-thread pool, and not invalidated in time before the session was closed. --- libs/ardour/ardour/session.h | 4 ++-- libs/ardour/session.cc | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'libs/ardour') diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h index 9326c9b948..3b15c2d7e2 100644 --- a/libs/ardour/ardour/session.h +++ b/libs/ardour/ardour/session.h @@ -1783,8 +1783,8 @@ private: public: /* Emited when a new source is added to the session */ - PBD::Signal1< void, boost::shared_ptr > SourceAdded; - PBD::Signal1< void, boost::shared_ptr > SourceRemoved; + PBD::Signal1< void, boost::weak_ptr > SourceAdded; + PBD::Signal1< void, boost::weak_ptr > SourceRemoved; typedef std::map > SourceMap; diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc index 499cf73379..5ca8f9207d 100644 --- a/libs/ardour/session.cc +++ b/libs/ardour/session.cc @@ -4277,7 +4277,7 @@ Session::destroy_sources (list > const& srcs) (*s)->mark_for_remove (); (*s)->drop_references (); - SourceRemoved(*s); + SourceRemoved (boost::weak_ptr (*s)); /* EMIT SIGNAL */ } return 0; @@ -4369,7 +4369,7 @@ Session::add_source (boost::shared_ptr source) source->DropReferences.connect_same_thread (*this, boost::bind (&Session::remove_source, this, boost::weak_ptr (source))); - SourceAdded(source); + SourceAdded (boost::weak_ptr (source)); /* EMIT SIGNAL */ } } @@ -4392,7 +4392,7 @@ Session::remove_source (boost::weak_ptr src) if ((i = sources.find (source->id())) != sources.end()) { sources.erase (i); - SourceRemoved(source); + SourceRemoved (src); /* EMIT SIGNAL */ } } -- cgit v1.2.3