fix crash when zoom level leads to multiple tempo lines on the same pixel (may affect several mantis reports)

git-svn-id: svn://localhost/ardour2/branches/3.0@14015 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Paul Davis 2013-01-27 22:42:36 +00:00
parent de4c4b5340
commit d04caca7ea

View file

@ -145,9 +145,7 @@ TempoLines::draw (const ARDOUR::TempoMap::BBTPointList::const_iterator& begin,
xpos = rint(((framepos_t)(*i).frame) / (double)frames_per_unit); xpos = rint(((framepos_t)(*i).frame) / (double)frames_per_unit);
if (inserted_last_time && !_lines.empty()) {
li = _lines.lower_bound(xpos); // first line >= xpos li = _lines.lower_bound(xpos); // first line >= xpos
}
line = (li != _lines.end()) ? li->second : NULL; line = (li != _lines.end()) ? li->second : NULL;
assert(!line || line->property_x1() == li->first); assert(!line || line->property_x1() == li->first);
@ -165,7 +163,6 @@ TempoLines::draw (const ARDOUR::TempoMap::BBTPointList::const_iterator& begin,
line->property_color_rgba() = color; line->property_color_rgba() = color;
inserted_last_time = false; // don't search next time inserted_last_time = false; // don't search next time
// Use existing line, moving if necessary // Use existing line, moving if necessary
} else if (!exhausted) { } else if (!exhausted) {
Lines::iterator steal = _lines.end(); Lines::iterator steal = _lines.end();
@ -216,7 +213,8 @@ TempoLines::draw (const ARDOUR::TempoMap::BBTPointList::const_iterator& begin,
// Create a new line // Create a new line
} else if (_lines.size() < needed || _lines.size() < MAX_CACHED_LINES) { } else if (_lines.size() < needed || _lines.size() < MAX_CACHED_LINES) {
//cout << "*** CREATING LINE" << endl; //cout << "*** CREATING LINE" << endl;
assert(_lines.find(xpos) == _lines.end()); /* if we already have a line there ... don't sweat it */
if (_lines.find (xpos) == _lines.end()) {
line = new ArdourCanvas::SimpleLine (*_group); line = new ArdourCanvas::SimpleLine (*_group);
line->property_x1() = xpos; line->property_x1() = xpos;
line->property_x2() = xpos; line->property_x2() = xpos;
@ -225,11 +223,12 @@ TempoLines::draw (const ARDOUR::TempoMap::BBTPointList::const_iterator& begin,
line->property_color_rgba() = color; line->property_color_rgba() = color;
_lines.insert(make_pair(xpos, line)); _lines.insert(make_pair(xpos, line));
inserted_last_time = true; inserted_last_time = true;
}
// Steal from the left // Steal from the left
} else { } else {
//cout << "*** STEALING FROM LEFT" << endl; //cout << "*** STEALING FROM LEFT" << endl;
assert(_lines.find(xpos) == _lines.end()); if (_lines.find (xpos) == _lines.end()) {
Lines::iterator steal = _lines.begin(); Lines::iterator steal = _lines.begin();
double const x = steal->first; double const x = steal->first;
line = steal->second; line = steal->second;
@ -246,6 +245,7 @@ TempoLines::draw (const ARDOUR::TempoMap::BBTPointList::const_iterator& begin,
_clean_right = max(_clean_right, xpos); _clean_right = max(_clean_right, xpos);
} }
} }
}
// Extend range to what we've 'fixed' // Extend range to what we've 'fixed'
if (!invalidated) { if (!invalidated) {