fix potential crash-causing coding errors when removing regionviews from the selection
git-svn-id: svn://localhost/ardour2/trunk@1693 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
39059bf339
commit
3b885c3126
@ -114,31 +114,33 @@ RegionSelection::remove_it (RegionView *rv)
|
||||
bool
|
||||
RegionSelection::remove (RegionView* rv)
|
||||
{
|
||||
RegionSelection::iterator i;
|
||||
RegionSelection::iterator r;
|
||||
|
||||
if ((i = find (begin(), end(), rv)) != end()) {
|
||||
|
||||
erase (i);
|
||||
if ((r = find (begin(), end(), rv)) != end()) {
|
||||
|
||||
// remove from layer sorted list
|
||||
_bylayer.remove (rv);
|
||||
|
||||
if (empty()) {
|
||||
if (size() == 1) {
|
||||
|
||||
/* this is the last one, so when we delete it
|
||||
we will be empty.
|
||||
*/
|
||||
|
||||
_current_start = 0;
|
||||
_current_end = 0;
|
||||
|
||||
} else {
|
||||
|
||||
boost::shared_ptr<Region> region ((*i)->region());
|
||||
|
||||
boost::shared_ptr<Region> region ((*r)->region());
|
||||
|
||||
if (region->first_frame() == _current_start) {
|
||||
|
||||
/* reset current start */
|
||||
|
||||
nframes_t ref = max_frames;
|
||||
|
||||
for (i = begin (); i != end(); ++i) {
|
||||
for (RegionSelection::iterator i = begin (); i != end(); ++i) {
|
||||
if (region->first_frame() < ref) {
|
||||
ref = region->first_frame();
|
||||
}
|
||||
@ -154,7 +156,7 @@ RegionSelection::remove (RegionView* rv)
|
||||
|
||||
nframes_t ref = 0;
|
||||
|
||||
for (i = begin (); i != end(); ++i) {
|
||||
for (RegionSelection::iterator i = begin (); i != end(); ++i) {
|
||||
if (region->first_frame() > ref) {
|
||||
ref = region->first_frame();
|
||||
}
|
||||
@ -164,6 +166,8 @@ RegionSelection::remove (RegionView* rv)
|
||||
}
|
||||
}
|
||||
|
||||
erase (r);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user