fix dangling references to a MidiRegion and MidiTrack in a MidiView
This commit is contained in:
@@ -174,6 +174,7 @@ MidiView::MidiView (MidiView const & other)
|
||||
void
|
||||
MidiView::init ()
|
||||
{
|
||||
_midi_track->DropReferences.connect (track_going_away_connection, invalidator (*this), boost::bind (&MidiView::track_going_away, this), gui_context());
|
||||
_patch_change_outline = UIConfiguration::instance().color ("midi patch change outline");
|
||||
_patch_change_fill = UIConfiguration::instance().color_mod ("midi patch change fill", "midi patch change fill");
|
||||
|
||||
@@ -181,15 +182,31 @@ MidiView::init ()
|
||||
EditingContext::DropDownKeys.connect (sigc::mem_fun (*this, &MidiView::drop_down_keys));
|
||||
}
|
||||
|
||||
void
|
||||
MidiView::track_going_away ()
|
||||
{
|
||||
_midi_track.reset ();
|
||||
}
|
||||
|
||||
void
|
||||
MidiView::region_going_away ()
|
||||
{
|
||||
_midi_region.reset ();
|
||||
_model.reset ();
|
||||
connections_requiring_model.drop_connections();
|
||||
}
|
||||
|
||||
void
|
||||
MidiView::set_region (std::shared_ptr<MidiRegion> mr)
|
||||
{
|
||||
_midi_region = mr;
|
||||
if (!_midi_region) {
|
||||
_model.reset ();
|
||||
connections_requiring_model.drop_connections();
|
||||
region_going_away ();
|
||||
return;
|
||||
}
|
||||
|
||||
_midi_region->DropReferences.connect (region_going_away_connection, invalidator (*this), boost::bind (&MidiView::region_going_away, this), gui_context());
|
||||
|
||||
set_model (_midi_region->midi_source (0)->model());
|
||||
}
|
||||
|
||||
|
||||
@@ -444,6 +444,10 @@ class MidiView : public virtual sigc::trackable
|
||||
bool note_canvas_event(GdkEvent* ev);
|
||||
|
||||
PBD::ScopedConnectionList connections_requiring_model;
|
||||
PBD::ScopedConnection track_going_away_connection;
|
||||
PBD::ScopedConnection region_going_away_connection;
|
||||
void track_going_away ();
|
||||
void region_going_away ();
|
||||
|
||||
void midi_channel_mode_changed ();
|
||||
void instrument_settings_changed ();
|
||||
|
||||
Reference in New Issue
Block a user