Fix crash when showing MIDI regions we shouldn't.

I am not sure what causes this, but it can happen when finishing a record
sometimes.  Probably MidiSource::_writing isn't updated in the right order with
whatever triggers the redisplay, but at least not crashing is better...
This commit is contained in:
David Robillard 2014-12-06 16:46:00 -05:00
parent 60f4f5b9d8
commit 9f5023175f

View File

@ -176,19 +176,28 @@ MidiStreamView::display_region(MidiRegionView* region_view, bool load_model)
}
region_view->enable_display (true);
region_view->set_height (child_height());
boost::shared_ptr<MidiSource> source(region_view->midi_region()->midi_source(0));
if (!source) {
error << _("attempt to display MIDI region with no source") << endmsg;
return;
}
if (load_model) {
source->load_model();
}
if (!source->model()) {
error << _("attempt to display MIDI region with no model") << endmsg;
return;
}
_range_dirty = update_data_note_range(
source->model()->lowest_note(),
source->model()->highest_note());
// Display region contents
region_view->set_height (child_height());
region_view->display_model(source->model());
}