summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gtk2_ardour/canvas-simplerect.c4
-rw-r--r--gtk2_ardour/editor_ops.cc9
-rw-r--r--gtk2_ardour/selection.cc2
-rw-r--r--libs/ardour/ardour/playlist.h6
-rw-r--r--libs/ardour/ardour/source.h4
-rw-r--r--libs/ardour/audioregion.cc5
-rw-r--r--libs/ardour/playlist.cc13
-rw-r--r--libs/ardour/source.cc21
8 files changed, 52 insertions, 12 deletions
diff --git a/gtk2_ardour/canvas-simplerect.c b/gtk2_ardour/canvas-simplerect.c
index e7a7488061..d50943f0c3 100644
--- a/gtk2_ardour/canvas-simplerect.c
+++ b/gtk2_ardour/canvas-simplerect.c
@@ -354,8 +354,8 @@ gnome_canvas_simplerect_reset_bounds (GnomeCanvasItem *item)
gnome_canvas_request_redraw (item->canvas,
unionrect.x0 - 0.5,
unionrect.y0 - 0.5,
- unionrect.x1 + 0.5,
- unionrect.y1 + 0.5);
+ unionrect.x1 + 1.5,
+ unionrect.y1 + 1.5);
}
/*
diff --git a/gtk2_ardour/editor_ops.cc b/gtk2_ardour/editor_ops.cc
index ba874fc7cf..e6c5790133 100644
--- a/gtk2_ardour/editor_ops.cc
+++ b/gtk2_ardour/editor_ops.cc
@@ -2811,19 +2811,21 @@ Editor::cut_copy_regions (CutCopyOp op)
}
boost::shared_ptr<AudioRegion> ar = boost::dynamic_pointer_cast<AudioRegion>((*x)->region());
+ boost::shared_ptr<Region> _xx;
switch (op) {
case Cut:
if (!ar) break;
- npl->add_region (RegionFactory::create (ar), (*x)->region()->position() - first_position);
+ _xx = RegionFactory::create ((*x)->region());
+ npl->add_region (_xx, (*x)->region()->position() - first_position);
pl->remove_region (((*x)->region()));
break;
case Copy:
if (!ar) break;
- npl->add_region (RegionFactory::create (ar), (*x)->region()->position() - first_position);
+ npl->add_region ((*x)->region(), (*x)->region()->position() - first_position);
break;
case Clear:
@@ -2843,10 +2845,11 @@ Editor::cut_copy_regions (CutCopyOp op)
foo.push_back ((*i).pl);
}
+
if (!foo.empty()) {
cut_buffer->set (foo);
}
-
+
for (set<PlaylistState, lt_playlist>::iterator pl = freezelist.begin(); pl != freezelist.end(); ++pl) {
(*pl).playlist->thaw ();
session->add_command (new MementoCommand<Playlist>(*(*pl).playlist, (*pl).before, &(*pl).playlist->get_state()));
diff --git a/gtk2_ardour/selection.cc b/gtk2_ardour/selection.cc
index 8a9d27a4ed..2b1b522d12 100644
--- a/gtk2_ardour/selection.cc
+++ b/gtk2_ardour/selection.cc
@@ -131,6 +131,8 @@ Selection::clear_playlists ()
/* Selections own their playlists */
for (PlaylistSelection::iterator i = playlists.begin(); i != playlists.end(); ++i) {
+ /* selections own their own regions, which are copies of the "originals". make them go away */
+ (*i)->drop_regions ();
(*i)->release ();
}
diff --git a/libs/ardour/ardour/playlist.h b/libs/ardour/ardour/playlist.h
index 6e36d3120b..103e95929e 100644
--- a/libs/ardour/ardour/playlist.h
+++ b/libs/ardour/ardour/playlist.h
@@ -138,6 +138,12 @@ class Playlist : public PBD::StatefulDestructible, public boost::enable_shared_f
virtual bool destroy_region (boost::shared_ptr<Region>) = 0;
+ /* special case function used by UI selection objects, which have playlists that actually own the regions
+ within them.
+ */
+
+ void drop_regions ();
+
protected:
friend class Session;
diff --git a/libs/ardour/ardour/source.h b/libs/ardour/ardour/source.h
index ae63b8c5fb..7ffa616a40 100644
--- a/libs/ardour/ardour/source.h
+++ b/libs/ardour/ardour/source.h
@@ -63,7 +63,9 @@ class Source : public PBD::StatefulDestructible
string _name;
time_t _timestamp;
- std::set<boost::shared_ptr<ARDOUR::Playlist> > _playlists;
+ Glib::Mutex playlist_lock;
+ typedef std::map<boost::shared_ptr<ARDOUR::Playlist>, uint32_t > PlaylistMap;
+ PlaylistMap _playlists;
private:
uint32_t _in_use;
diff --git a/libs/ardour/audioregion.cc b/libs/ardour/audioregion.cc
index 24249a6364..db6e5fc089 100644
--- a/libs/ardour/audioregion.cc
+++ b/libs/ardour/audioregion.cc
@@ -1057,7 +1057,6 @@ AudioRegion::separate_by_channel (Session& session, vector<boost::shared_ptr<Aud
boost::shared_ptr<Region> r = RegionFactory::create (srcs, _start, _length, new_name, _layer, f);
boost::shared_ptr<AudioRegion> ar = boost::dynamic_pointer_cast<AudioRegion> (r);
- cerr << "new region name is " << ar->name() << endl;
v.push_back (ar);
@@ -1281,7 +1280,6 @@ AudioRegion::normalize_to (float target_dB)
boost::shared_ptr<Playlist> pl (playlist());
if (pl) {
- cerr << "Send modified\n";
pl->Modified();
}
@@ -1368,6 +1366,7 @@ void
AudioRegion::set_playlist (boost::weak_ptr<Playlist> wpl)
{
boost::shared_ptr<Playlist> old_playlist = (_playlist.lock());
+
boost::shared_ptr<Playlist> pl (wpl.lock());
if (old_playlist == pl) {
@@ -1390,7 +1389,7 @@ AudioRegion::set_playlist (boost::weak_ptr<Playlist> wpl)
} else {
if (old_playlist) {
for (SourceList::const_iterator i = sources.begin(); i != sources.end(); ++i) {
- (*i)->remove_playlist (_playlist);
+ (*i)->remove_playlist (old_playlist);
}
}
}
diff --git a/libs/ardour/playlist.cc b/libs/ardour/playlist.cc
index 496be33950..ae9e23fcc9 100644
--- a/libs/ardour/playlist.cc
+++ b/libs/ardour/playlist.cc
@@ -574,6 +574,11 @@ Playlist::remove_region_internal (boost::shared_ptr<Region>region)
old_length = _get_maximum_extent();
}
+ if (!in_set_state) {
+ /* unset playlist */
+ region->set_playlist (boost::weak_ptr<Playlist>());
+ }
+
for (i = regions.begin(); i != regions.end(); ++i) {
if (*i == region) {
@@ -1175,6 +1180,14 @@ Playlist::region_changed (Change what_changed, boost::shared_ptr<Region> region)
}
void
+Playlist::drop_regions ()
+{
+ RegionLock rl (this);
+ regions.clear ();
+ all_regions.clear ();
+}
+
+void
Playlist::clear (bool with_signals)
{
{
diff --git a/libs/ardour/source.cc b/libs/ardour/source.cc
index fe14fc72af..7f680e7100 100644
--- a/libs/ardour/source.cc
+++ b/libs/ardour/source.cc
@@ -111,7 +111,17 @@ Source::set_state (const XMLNode& node)
void
Source::add_playlist (boost::shared_ptr<Playlist> pl)
{
- _playlists.insert (pl);
+ std::pair<PlaylistMap::iterator,bool> res;
+ std::pair<boost::shared_ptr<Playlist>, uint32_t> newpair (pl, 1);
+ Glib::Mutex::Lock lm (playlist_lock);
+
+ res = _playlists.insert (newpair);
+
+ if (!res.second) {
+ /* it already existed, bump count */
+ res.first->second++;
+ }
+
pl->GoingAway.connect (bind (mem_fun (*this, &Source::remove_playlist), boost::weak_ptr<Playlist> (pl)));
}
@@ -124,10 +134,15 @@ Source::remove_playlist (boost::weak_ptr<Playlist> wpl)
return;
}
- std::set<boost::shared_ptr<Playlist> >::iterator x;
+ PlaylistMap::iterator x;
+ Glib::Mutex::Lock lm (playlist_lock);
if ((x = _playlists.find (pl)) != _playlists.end()) {
- _playlists.erase (x);
+ if (x->second > 1) {
+ x->second--;
+ } else {
+ _playlists.erase (x);
+ }
}
}