Fix thinko causing possible memory corruption.
[ardour.git] / gtk2_ardour / tempo_lines.cc
index 1ee73c72809c1d5872c9aae6f33eafbd97bf88a2..ace2426bace74e13236f2856bd7d832559798831 100644 (file)
@@ -48,8 +48,9 @@ TempoLines::tempo_map_changed()
                ++next;
                i->second->property_x1() = - d;
                i->second->property_x2() = - d;
+               ArdourCanvas::SimpleLine* f = i->second;
                _lines.erase(i);
-               _lines.insert(make_pair(- d, i->second));
+               _lines.insert(make_pair(- d, f));
                i = next;
        }
 }
@@ -133,7 +134,7 @@ TempoLines::draw (const ARDOUR::TempoMap::BBTPointList::const_iterator& begin,
 
        for (i = begin; i != end; ++i) {
 
-               if ((*i).type == ARDOUR::TempoMap::Bar) {
+               if ((*i).is_bar()) {
                        color = ARDOUR_UI::config()->canvasvar_MeasureLineBar.get();
                } else {
                        if (beat_density > 2.0) {
@@ -173,6 +174,7 @@ TempoLines::draw (const ARDOUR::TempoMap::BBTPointList::const_iterator& begin,
                        // Steal from the right
                        if (left->first > needed_left && li != steal && steal->first > needed_right) {
                                //cout << "*** STEALING FROM RIGHT" << endl;
+                               double const x = steal->first;
                                line = steal->second;
                                _lines.erase(steal);
                                line->property_x1() = xpos;
@@ -184,7 +186,7 @@ TempoLines::draw (const ARDOUR::TempoMap::BBTPointList::const_iterator& begin,
                                
                                // Shift clean range left
                                _clean_left = min(_clean_left, xpos);
-                               _clean_right = min(_clean_right, steal->first);
+                               _clean_right = min(_clean_right, x);
                                
                                // Move this line to where we need it
                        } else {
@@ -229,6 +231,7 @@ TempoLines::draw (const ARDOUR::TempoMap::BBTPointList::const_iterator& begin,
                        //cout << "*** STEALING FROM LEFT" << endl;
                        assert(_lines.find(xpos) == _lines.end());
                        Lines::iterator steal = _lines.begin();
+                       double const x = steal->first;
                        line = steal->second;
                        _lines.erase(steal);
                        line->property_color_rgba() = color;
@@ -239,7 +242,7 @@ TempoLines::draw (const ARDOUR::TempoMap::BBTPointList::const_iterator& begin,
                        invalidated = true;
                        
                        // Shift clean range right
-                       _clean_left = max(_clean_left, steal->first);
+                       _clean_left = max(_clean_left, x);
                        _clean_right = max(_clean_right, xpos);
                }
        }