diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc index 1d6c820406..68dc02bfbe 100644 --- a/gtk2_ardour/editor_drag.cc +++ b/gtk2_ardour/editor_drag.cc @@ -7476,8 +7476,10 @@ AutomationDrawDrag::finished (GdkEvent* event, bool motion_occured) FreehandLineDrag::finished (event, motion_occured); MergeableLine* ml = lm->make_merger(); - ml->merge_drawn_line (editing_context, *editing_context.session(), drawn_points, !did_snap); - delete ml; + if (ml) { + ml->merge_drawn_line (editing_context, *editing_context.session(), drawn_points, !did_snap); + delete ml; + } } /*****************/ diff --git a/gtk2_ardour/midi_cue_editor.cc b/gtk2_ardour/midi_cue_editor.cc index 7be2b57121..9553affc4f 100644 --- a/gtk2_ardour/midi_cue_editor.cc +++ b/gtk2_ardour/midi_cue_editor.cc @@ -256,6 +256,10 @@ MidiCueEditor::set_visible_channel (int n) { _visible_channel = n; visible_channel_label.set_text (string_compose (_("MIDI Channel %1"), _visible_channel + 1)); + + if (view) { + view->swap_automation_channel (n); + } } void diff --git a/gtk2_ardour/midi_cue_view.cc b/gtk2_ardour/midi_cue_view.cc index 374d784665..eaa13870d4 100644 --- a/gtk2_ardour/midi_cue_view.cc +++ b/gtk2_ardour/midi_cue_view.cc @@ -235,6 +235,43 @@ MidiCueView::update_hit (Hit* h) } } +void +MidiCueView::swap_automation_channel (int new_channel) +{ + std::vector new_params; + Evoral::Parameter active (0, 0, 0); + bool have_active = false; + + /* Make a note of what was visible, but use the new channel */ + + for (CueAutomationMap::iterator i = automation_map.begin(); i != automation_map.end(); ++i) { + if (i->second.visible) { + Evoral::Parameter param (i->first.type(), new_channel, i->first.id()); + new_params.push_back (param); + if (&i->second == active_automation) { + active = param; + have_active = true; + } + } + } + + /* Drop the old */ + + automation_map.clear (); + + /* Create the new */ + + for (auto const & p : new_params) { + update_automation_display (p, SelectionAdd); + } + + if (have_active) { + set_active_automation (active); + } else { + unset_active_automation (); + } +} + void MidiCueView::update_automation_display (Evoral::Parameter const & param, SelectionOperation op) { diff --git a/gtk2_ardour/midi_cue_view.h b/gtk2_ardour/midi_cue_view.h index c129536922..0ee38bb525 100644 --- a/gtk2_ardour/midi_cue_view.h +++ b/gtk2_ardour/midi_cue_view.h @@ -61,6 +61,7 @@ class MidiCueView : public MidiView void ghost_sync_selection (NoteBase*); void update_automation_display (Evoral::Parameter const & param, ARDOUR::SelectionOperation); + void swap_automation_channel (int); void set_active_automation (Evoral::Parameter const &); bool is_active_automation (Evoral::Parameter const &) const; bool is_visible_automation (Evoral::Parameter const &) const;