summaryrefslogtreecommitdiff
path: root/libs/ardour/region_factory.cc
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2010-03-06 15:40:42 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2010-03-06 15:40:42 +0000
commitb6b68881b2c59c216d2195b1cea5e667187d83ed (patch)
tree6f6cae22e8d2175bbc54d428472402cd2d73eb2c /libs/ardour/region_factory.cc
parent4ffcec7b7974f9fb65b2da295cbadb219f2a1970 (diff)
remove the session region list; GUI now represents (a relatively unfiltered view of) the raw region list that always contains every single region ever created
git-svn-id: svn://localhost/ardour2/branches/3.0@6739 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/region_factory.cc')
-rw-r--r--libs/ardour/region_factory.cc55
1 files changed, 46 insertions, 9 deletions
diff --git a/libs/ardour/region_factory.cc b/libs/ardour/region_factory.cc
index 3f4af2462c..8a24bc954c 100644
--- a/libs/ardour/region_factory.cc
+++ b/libs/ardour/region_factory.cc
@@ -38,6 +38,7 @@ using namespace PBD;
PBD::Signal1<void,boost::shared_ptr<Region> > RegionFactory::CheckNewRegion;
Glib::StaticMutex RegionFactory::region_map_lock;
RegionFactory::RegionMap RegionFactory::region_map;
+PBD::ScopedConnectionList RegionFactory::region_list_connections;
boost::shared_ptr<Region>
RegionFactory::create (boost::shared_ptr<const Region> region)
@@ -287,7 +288,6 @@ RegionFactory::create (SourceList& srcs, const XMLNode& node)
return ret;
}
-
void
RegionFactory::map_add (boost::shared_ptr<Region> r)
{
@@ -298,19 +298,19 @@ RegionFactory::map_add (boost::shared_ptr<Region> r)
{
Glib::Mutex::Lock lm (region_map_lock);
region_map.insert (p);
- /* we pay no attention to attempts to delete regions */
}
+
+ r->DropReferences.connect_same_thread (region_list_connections, boost::bind (&RegionFactory::map_remove, r));
}
void
RegionFactory::map_remove (boost::shared_ptr<Region> r)
{
- {
- Glib::Mutex::Lock lm (region_map_lock);
- RegionMap::iterator i = region_map.find (r->id());
- if (i != region_map.end()) {
- region_map.erase (i);
- }
+ Glib::Mutex::Lock lm (region_map_lock);
+ RegionMap::iterator i = region_map.find (r->id());
+
+ if (i != region_map.end()) {
+ region_map.erase (i);
}
}
@@ -330,5 +330,42 @@ RegionFactory::region_by_id (const PBD::ID& id)
void
RegionFactory::clear_map ()
{
- region_map.clear ();
+ region_list_connections.drop_connections ();
+
+ {
+ Glib::Mutex::Lock lm (region_map_lock);
+ region_map.clear ();
+ }
+
+}
+
+void
+RegionFactory::delete_all_regions ()
+{
+ RegionMap copy;
+
+ /* copy region list */
+ {
+ Glib::Mutex::Lock lm (region_map_lock);
+ copy = region_map;
+ }
+
+ /* clear existing map */
+ clear_map ();
+
+ /* tell everyone to drop references */
+ for (RegionMap::iterator i = copy.begin(); i != copy.end(); ++i) {
+ i->second->drop_references ();
+ }
+
+ /* the copy should now hold the only references, which will
+ vanish as we leave this scope, thus calling all destructors.
+ */
+}
+
+uint32_t
+RegionFactory::nregions ()
+{
+ Glib::Mutex::Lock lm (region_map_lock);
+ return region_map.size ();
}