fix set/unset of Pianoroll::ref (trigger reference) when a region is set

We do want to reset things like history, but not lose the trigger reference, if any
This commit is contained in:
Paul Davis
2025-05-16 16:43:03 -06:00
parent 72bb24bb1b
commit 01a087985e
3 changed files with 12 additions and 10 deletions

View File

@@ -2434,7 +2434,7 @@ Pianoroll::rec_button_press (GdkEventButton* ev)
}
void
Pianoroll::set (TriggerReference & tref)
Pianoroll::set_trigger (TriggerReference & tref)
{
if (tref.trigger() == ref.trigger()) {
return;
@@ -2462,7 +2462,7 @@ Pianoroll::set (TriggerReference & tref)
set_track (_track);
_track->DropReferences.connect (object_connections, invalidator (*this), std::bind (&Pianoroll::unset, this), gui_context());
_track->DropReferences.connect (object_connections, invalidator (*this), std::bind (&Pianoroll::unset, this, true), gui_context());
ref.trigger()->PropertyChanged.connect (object_connections, invalidator (*this), std::bind (&Pianoroll::trigger_prop_change, this, _1), gui_context());
ref.trigger()->ArmChanged.connect (object_connections, invalidator (*this), std::bind (&Pianoroll::trigger_arm_change, this), gui_context());
@@ -2504,14 +2504,16 @@ Pianoroll::make_a_region ()
}
void
Pianoroll::unset ()
Pianoroll::unset (bool trigger_too)
{
_history.clear ();
_update_connection.disconnect();
object_connections.drop_connections ();
_track.reset ();
view->set_region (nullptr);
ref = TriggerReference ();
if (trigger_too) {
ref = TriggerReference ();
}
}
void
@@ -2556,7 +2558,7 @@ Pianoroll::update_solo_display ()
void
Pianoroll::set_region (std::shared_ptr<ARDOUR::MidiRegion> r)
{
unset ();
unset (false);
if (!r) {
return;
@@ -2566,7 +2568,7 @@ Pianoroll::set_region (std::shared_ptr<ARDOUR::MidiRegion> r)
view->show_start (true);
view->show_end (true);
r->DropReferences.connect (object_connections, invalidator (*this), std::bind (&Pianoroll::unset, this), gui_context());
r->DropReferences.connect (object_connections, invalidator (*this), std::bind (&Pianoroll::unset, this, false), gui_context());
r->PropertyChanged.connect (object_connections, invalidator (*this), std::bind (&Pianoroll::region_prop_change, this, _1), gui_context());
bool provided = false;

View File

@@ -81,7 +81,7 @@ class Pianoroll : public CueEditor
int32_t get_grid_beat_divisions (Editing::GridType gt) const { return 1; }
int32_t get_grid_music_divisions (Editing::GridType gt, uint32_t event_state) const { return 1; }
void set (ARDOUR::TriggerReference&);
void set_trigger (ARDOUR::TriggerReference&);
void set_region (std::shared_ptr<ARDOUR::MidiRegion>);
void set_track (std::shared_ptr<ARDOUR::MidiTrack>);
@@ -272,7 +272,7 @@ class Pianoroll : public CueEditor
void trigger_prop_change (PBD::PropertyChange const &);
void region_prop_change (PBD::PropertyChange const &);
void unset ();
void unset (bool trigger_too);
void visual_changer (const VisualChange&);
void bindings_changed ();

View File

@@ -497,7 +497,7 @@ TriggerPage::trigger_arm_changed (Trigger const * trigger)
_midi_trig_box.set_trigger (ref);
_midi_trig_box.show ();
_midi_editor->set (ref);
_midi_editor->set_trigger (ref);
_midi_editor->viewport().show ();
}
@@ -548,7 +548,7 @@ TriggerPage::selection_changed ()
_midi_trig_box.set_trigger (ref);
_midi_trig_box.show ();
_midi_editor->set (ref);
_midi_editor->set_trigger (ref);
table.attach (_midi_editor->contents(), clip_editor_column, clip_editor_column + 1, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL);
_midi_editor->contents().show_all ();