summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2014-02-12 15:13:11 -0500
committerPaul Davis <paul@linuxaudiosystems.com>2014-02-12 15:13:11 -0500
commit937cb4fd2b0c5e9e8e4d883f31f7c4dd2bb2ac08 (patch)
treea9fc688c0f6889e5933357cb8d18ba0c1d71dd2e
parent8f930477be9e2c88859a8ea30b213fba3f7fc443 (diff)
convert canvas items that compose the playhead (EditorCursor, more generally) to pointers, since canvas items are owned by the group they belong to. This avoids a double-free during deletion
-rw-r--r--gtk2_ardour/editor_cursors.cc54
-rw-r--r--gtk2_ardour/editor_cursors.h8
2 files changed, 31 insertions, 31 deletions
diff --git a/gtk2_ardour/editor_cursors.cc b/gtk2_ardour/editor_cursors.cc
index 59b81b2b48..1dd0d42a51 100644
--- a/gtk2_ardour/editor_cursors.cc
+++ b/gtk2_ardour/editor_cursors.cc
@@ -33,27 +33,27 @@ using namespace Gtk;
EditorCursor::EditorCursor (Editor& ed, bool (Editor::*callbck)(GdkEvent*,ArdourCanvas::Item*))
: _editor (ed)
- , _time_bars_canvas_item (_editor._time_bars_canvas->root ())
- , _track_canvas_item (_editor._track_canvas->root ())
+ , _time_bars_canvas_item (new ArdourCanvas::Arrow (_editor._time_bars_canvas->root ()))
+ , _track_canvas_item (new ArdourCanvas::Line (_editor._track_canvas->root ()))
, _length (1.0)
{
- CANVAS_DEBUG_NAME ((&_time_bars_canvas_item), "timebars editor cursor");
- CANVAS_DEBUG_NAME ((&_track_canvas_item), "track canvas editor cursor");
+ CANVAS_DEBUG_NAME (_time_bars_canvas_item, "timebars editor cursor");
+ CANVAS_DEBUG_NAME (_track_canvas_item, "track canvas editor cursor");
- _time_bars_canvas_item.set_show_head (0, true);
- _time_bars_canvas_item.set_head_height (0, 9);
- _time_bars_canvas_item.set_head_width (0, 16);
- _time_bars_canvas_item.set_head_outward (0, false);
- _time_bars_canvas_item.set_show_head (1, false); // head only
+ _time_bars_canvas_item->set_show_head (0, true);
+ _time_bars_canvas_item->set_head_height (0, 9);
+ _time_bars_canvas_item->set_head_width (0, 16);
+ _time_bars_canvas_item->set_head_outward (0, false);
+ _time_bars_canvas_item->set_show_head (1, false); // head only
- _time_bars_canvas_item.set_data ("cursor", this);
- _track_canvas_item.set_data ("cursor", this);
+ _time_bars_canvas_item->set_data ("cursor", this);
+ _track_canvas_item->set_data ("cursor", this);
- _time_bars_canvas_item.Event.connect (sigc::bind (sigc::mem_fun (ed, callbck), &_time_bars_canvas_item));
- _track_canvas_item.Event.connect (sigc::bind (sigc::mem_fun (ed, callbck), &_track_canvas_item));
+ _time_bars_canvas_item->Event.connect (sigc::bind (sigc::mem_fun (ed, callbck), _time_bars_canvas_item));
+ _track_canvas_item->Event.connect (sigc::bind (sigc::mem_fun (ed, callbck), _track_canvas_item));
- _time_bars_canvas_item.set_y1 (ArdourCanvas::COORD_MAX);
- _track_canvas_item.set_y1 (ArdourCanvas::COORD_MAX);
+ _time_bars_canvas_item->set_y1 (ArdourCanvas::COORD_MAX);
+ _track_canvas_item->set_y1 (ArdourCanvas::COORD_MAX);
_current_frame = 1; /* force redraw at 0 */
}
@@ -68,36 +68,36 @@ EditorCursor::set_position (framepos_t frame)
{
PositionChanged (frame);
- double const new_pos = _editor.sample_to_pixel (frame);
+ double const new_pos = _editor.sample_to_pixel_unrounded (frame);
- if (new_pos != _time_bars_canvas_item.x ()) {
- _time_bars_canvas_item.set_x (new_pos);
+ if (new_pos != _time_bars_canvas_item->x ()) {
+ _time_bars_canvas_item->set_x (new_pos);
}
- if (new_pos != _track_canvas_item.x0 ()) {
- _track_canvas_item.set_x (new_pos, new_pos);
+ if (new_pos != _track_canvas_item->x0 ()) {
+ _track_canvas_item->set_x (new_pos, new_pos);
}
-
+
_current_frame = frame;
}
void
EditorCursor::show ()
{
- _time_bars_canvas_item.show ();
- _track_canvas_item.show ();
+ _time_bars_canvas_item->show ();
+ _track_canvas_item->show ();
}
void
EditorCursor::hide ()
{
- _time_bars_canvas_item.hide ();
- _track_canvas_item.hide ();
+ _time_bars_canvas_item->hide ();
+ _track_canvas_item->hide ();
}
void
EditorCursor::set_color (ArdourCanvas::Color color)
{
- _time_bars_canvas_item.set_color (color);
- _track_canvas_item.set_outline_color (color);
+ _time_bars_canvas_item->set_color (color);
+ _track_canvas_item->set_outline_color (color);
}
diff --git a/gtk2_ardour/editor_cursors.h b/gtk2_ardour/editor_cursors.h
index 93689c6e7b..4a2d20e8f8 100644
--- a/gtk2_ardour/editor_cursors.h
+++ b/gtk2_ardour/editor_cursors.h
@@ -42,19 +42,19 @@ class EditorCursor {
}
ArdourCanvas::Line& track_canvas_item () {
- return _track_canvas_item;
+ return *_track_canvas_item;
}
ArdourCanvas::Arrow& time_bar_canvas_item () {
- return _time_bars_canvas_item;
+ return *_time_bars_canvas_item;
}
PBD::Signal1<void, framepos_t> PositionChanged;
private:
Editor& _editor;
- ArdourCanvas::Arrow _time_bars_canvas_item;
- ArdourCanvas::Line _track_canvas_item;
+ ArdourCanvas::Arrow* _time_bars_canvas_item;
+ ArdourCanvas::Line* _track_canvas_item;
framepos_t _current_frame;
double _length;
};