fix pathscanner / stl_vector related memory leaks
[ardour.git] / gtk2_ardour / automation_time_axis.cc
index fd3c7aab52bb05488291335b83257d923d95f8ca..c6238e67111c9de0d9795e0d4d71362ab64b896d 100644 (file)
@@ -31,6 +31,8 @@
 #include "ardour/route.h"
 #include "ardour/session.h"
 
+#include "canvas/debug.h"
+
 #include "ardour_ui.h"
 #include "automation_time_axis.h"
 #include "automation_streamview.h"
@@ -82,12 +84,17 @@ AutomationTimeAxisView::AutomationTimeAxisView (
        , _control (c)
        , _automatable (a)
        , _parameter (p)
-       , _base_rect (0)
-       , _view (show_regions ? new AutomationStreamView (*this) : 0)
+       , _base_rect (new ArdourCanvas::Rectangle (_canvas_display))
        , _name (nom)
+       , _view (show_regions ? new AutomationStreamView (*this) : 0)
        , auto_button (X_("")) /* force addition of a label */
        , _show_regions (show_regions)
 {
+
+       CANVAS_DEBUG_NAME (_canvas_display, string_compose ("main for auto %2/%1", _name, r->name()));
+       CANVAS_DEBUG_NAME (selection_group, string_compose ("selections for auto %2/%1", _name, r->name()));
+       CANVAS_DEBUG_NAME (_ghost_group, string_compose ("ghosts for auto %2/%1", _name, r->name()));
+
        if (!have_name_font) {
                name_font = get_font_for_style (X_("AutomationTrackName"));
                have_name_font = true;
@@ -108,20 +115,13 @@ AutomationTimeAxisView::AutomationTimeAxisView (
        ignore_state_request = false;
        first_call_to_set_height = true;
 
-       _base_rect = new ArdourCanvas::Rectangle (_canvas_display);
+       CANVAS_DEBUG_NAME (_base_rect, string_compose ("base rect for %1", _name));
        _base_rect->set_x1 (ArdourCanvas::COORD_MAX);
        _base_rect->set_outline_color (ARDOUR_UI::config()->get_canvasvar_AutomationTrackOutline());
-
-       /* outline ends and bottom */
-       _base_rect->set_outline_what (0x1 | 0x2 | 0x8);
+       _base_rect->set_outline_what (ArdourCanvas::Rectangle::BOTTOM);
        _base_rect->set_fill_color (ARDOUR_UI::config()->get_canvasvar_AutomationTrackFill());
-
        _base_rect->set_data ("trackview", this);
-
-       _base_rect->Event.connect (sigc::bind (
-                       sigc::mem_fun (_editor, &PublicEditor::canvas_automation_track_event),
-                       _base_rect, this));
-
+       _base_rect->Event.connect (sigc::bind (sigc::mem_fun (_editor, &PublicEditor::canvas_automation_track_event), _base_rect, this));
        if (!a) {
                _base_rect->lower_to_bottom();
        }
@@ -489,22 +489,22 @@ AutomationTimeAxisView::build_display_menu ()
        as_items.push_back (CheckMenuElem (S_("Automation|Manual"), sigc::bind (
                        sigc::mem_fun(*this, &AutomationTimeAxisView::set_automation_state),
                        (AutoState) ARDOUR::Off)));
-       auto_off_item = dynamic_cast<CheckMenuItem*>(&as_items.back());
+       auto_off_item = dynamic_cast<Gtk::CheckMenuItem*>(&as_items.back());
 
        as_items.push_back (CheckMenuElem (_("Play"), sigc::bind (
                        sigc::mem_fun(*this, &AutomationTimeAxisView::set_automation_state),
                        (AutoState) Play)));
-       auto_play_item = dynamic_cast<CheckMenuItem*>(&as_items.back());
+       auto_play_item = dynamic_cast<Gtk::CheckMenuItem*>(&as_items.back());
 
        as_items.push_back (CheckMenuElem (_("Write"), sigc::bind (
                        sigc::mem_fun(*this, &AutomationTimeAxisView::set_automation_state),
                        (AutoState) Write)));
-       auto_write_item = dynamic_cast<CheckMenuItem*>(&as_items.back());
+       auto_write_item = dynamic_cast<Gtk::CheckMenuItem*>(&as_items.back());
 
        as_items.push_back (CheckMenuElem (_("Touch"), sigc::bind (
                        sigc::mem_fun(*this, &AutomationTimeAxisView::set_automation_state),
                        (AutoState) Touch)));
-       auto_touch_item = dynamic_cast<CheckMenuItem*>(&as_items.back());
+       auto_touch_item = dynamic_cast<Gtk::CheckMenuItem*>(&as_items.back());
 
        items.push_back (MenuElem (_("State"), *auto_state_menu));
 
@@ -524,13 +524,13 @@ AutomationTimeAxisView::build_display_menu ()
                am_items.push_back (RadioMenuElem (group, _("Discrete"), sigc::bind (
                                sigc::mem_fun(*this, &AutomationTimeAxisView::set_interpolation),
                                AutomationList::Discrete)));
-               mode_discrete_item = dynamic_cast<CheckMenuItem*>(&am_items.back());
+               mode_discrete_item = dynamic_cast<Gtk::CheckMenuItem*>(&am_items.back());
                mode_discrete_item->set_active (s == AutomationList::Discrete);
 
                am_items.push_back (RadioMenuElem (group, _("Linear"), sigc::bind (
                                sigc::mem_fun(*this, &AutomationTimeAxisView::set_interpolation),
                                AutomationList::Linear)));
-               mode_line_item = dynamic_cast<CheckMenuItem*>(&am_items.back());
+               mode_line_item = dynamic_cast<Gtk::CheckMenuItem*>(&am_items.back());
                mode_line_item->set_active (s == AutomationList::Linear);
 
                items.push_back (MenuElem (_("Mode"), *auto_mode_menu));
@@ -543,7 +543,7 @@ AutomationTimeAxisView::build_display_menu ()
 }
 
 void
-AutomationTimeAxisView::add_automation_event (GdkEvent* event, framepos_t when, double y)
+AutomationTimeAxisView::add_automation_event (GdkEvent* event, framepos_t when, double y, bool with_guard_points)
 {
        if (!_line) {
                return;
@@ -576,7 +576,7 @@ AutomationTimeAxisView::add_automation_event (GdkEvent* event, framepos_t when,
        _session->begin_reversible_command (_("add automation event"));
        XMLNode& before = list->get_state();
 
-       list->add (when, y);
+       list->add (when, y, with_guard_points);
 
        XMLNode& after = list->get_state();
        _session->commit_reversible_command (new MementoCommand<ARDOUR::AutomationList> (*list, &before, &after));