From f4401c59284258c6aa56707da64e3da32756329f Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Wed, 23 Jun 2010 20:14:07 +0000 Subject: midway snapshot of work done on managing Region & Source lifetimes correctly. may fix missing MIDI file bug ; save empty playlists because they may be referred to by the history file ; undo commands auto-delete when objects they refer to die (currently not commands built from XML deserialization); Sources now know how many regions are using them for something, meaning that we know if we can delete the files holding any data for the source git-svn-id: svn://localhost/ardour2/branches/3.0@7291 d708f5d6-7413-0410-9779-e7cbd77b26cf --- libs/ardour/region_factory.cc | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'libs/ardour/region_factory.cc') diff --git a/libs/ardour/region_factory.cc b/libs/ardour/region_factory.cc index 5a4b129710..65649ad8f7 100644 --- a/libs/ardour/region_factory.cc +++ b/libs/ardour/region_factory.cc @@ -73,6 +73,7 @@ RegionFactory::create (boost::shared_ptr region) } if (ret) { + cerr << "Pure copy constructor region " << ret << " named " << ret->name() << endl; map_add (ret); /* pure copy constructor - no property list */ @@ -124,6 +125,7 @@ RegionFactory::create (boost::shared_ptr region, frameoffset_t offset, b if (ret) { ret->set_properties (plist); + cerr << "Partial copy constructor region\n"; map_add (ret); if (announce) { @@ -163,6 +165,7 @@ RegionFactory::create (boost::shared_ptr region, const SourceList& srcs, if (ret) { ret->set_properties (plist); + cerr << "New sources copy constructor region\n"; map_add (ret); if (announce) { @@ -208,6 +211,7 @@ RegionFactory::create (const SourceList& srcs, const PropertyList& plist, bool a if (ret) { ret->set_properties (plist); + cerr << "de-novo constructor region " << ret << " named " << ret->name() << endl; map_add (ret); if (announce) { @@ -281,6 +285,8 @@ RegionFactory::map_add (boost::shared_ptr r) boost::bind (&RegionFactory::region_changed, _1, boost::weak_ptr (r)) ); + cerr << "Added region with ID = " << r->id() << " named " << r->name() << endl; + update_region_name_map (r); } @@ -292,7 +298,32 @@ RegionFactory::map_remove (boost::shared_ptr r) if (i != region_map.end()) { region_map.erase (i); + cerr << "Removed region with ID = " << r->id() << " named " << r->name() << endl;; } + +} + +void +RegionFactory::map_remove_with_equivalents (boost::shared_ptr r) +{ + Glib::Mutex::Lock lm (region_map_lock); + + for (RegionMap::iterator i = region_map.begin(); i != region_map.end(); ) { + RegionMap::iterator tmp = i; + ++tmp; + + if (r->region_list_equivalent (i->second)) { + cerr << "Removed equivalent region " << i->second->name() << '/' << i->first << endl; + region_map.erase (i); + } else if (r == i->second) { + cerr << "Removed actual region " << i->second->name() << '/' << i->first << endl; + region_map.erase (i); + } + + i = tmp; + } + + } boost::shared_ptr @@ -487,3 +518,15 @@ RegionFactory::new_region_name (string old) error << string_compose (_("cannot create new name for region \"%1\""), old) << endmsg; return old; } + +void +RegionFactory::get_regions_using_source (boost::shared_ptr s, std::set >& r) +{ + Glib::Mutex::Lock lm (region_map_lock); + + for (RegionMap::iterator i = region_map.begin(); i != region_map.end(); ++i) { + if (i->second->uses_source (s)) { + r.insert (i->second); + } + } +} -- cgit v1.2.3