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.
This commit is contained in:
Robin Gareus
2019-12-25 17:59:38 +01:00
parent df17e3f041
commit ab58c894d3
2 changed files with 5 additions and 5 deletions

View File

@@ -1783,8 +1783,8 @@ private:
public:
/* Emited when a new source is added to the session */
PBD::Signal1< void, boost::shared_ptr<Source> > SourceAdded;
PBD::Signal1< void, boost::shared_ptr<Source> > SourceRemoved;
PBD::Signal1< void, boost::weak_ptr<Source> > SourceAdded;
PBD::Signal1< void, boost::weak_ptr<Source> > SourceRemoved;
typedef std::map<PBD::ID,boost::shared_ptr<Source> > SourceMap;

View File

@@ -4277,7 +4277,7 @@ Session::destroy_sources (list<boost::shared_ptr<Source> > const& srcs)
(*s)->mark_for_remove ();
(*s)->drop_references ();
SourceRemoved(*s);
SourceRemoved (boost::weak_ptr<Source> (*s)); /* EMIT SIGNAL */
}
return 0;
@@ -4369,7 +4369,7 @@ Session::add_source (boost::shared_ptr<Source> source)
source->DropReferences.connect_same_thread (*this, boost::bind (&Session::remove_source, this, boost::weak_ptr<Source> (source)));
SourceAdded(source);
SourceAdded (boost::weak_ptr<Source> (source)); /* EMIT SIGNAL */
}
}
@@ -4392,7 +4392,7 @@ Session::remove_source (boost::weak_ptr<Source> src)
if ((i = sources.find (source->id())) != sources.end()) {
sources.erase (i);
SourceRemoved(source);
SourceRemoved (src); /* EMIT SIGNAL */
}
}