probably fix cleanup issues, but testing required

git-svn-id: svn://localhost/ardour2/trunk@1632 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Paul Davis 2007-03-21 02:39:12 +00:00
parent 6525aaeb70
commit 767984b486
8 changed files with 52 additions and 12 deletions

View File

@ -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);
}
/*

View File

@ -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()));

View File

@ -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 ();
}

View File

@ -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;

View File

@ -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;

View File

@ -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);
}
}
}

View File

@ -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) {
@ -1174,6 +1179,14 @@ Playlist::region_changed (Change what_changed, boost::shared_ptr<Region> region)
return save;
}
void
Playlist::drop_regions ()
{
RegionLock rl (this);
regions.clear ();
all_regions.clear ();
}
void
Playlist::clear (bool with_signals)
{

View File

@ -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);
}
}
}