fix crash when importing MIDI with "at timestamp" chosen

git-svn-id: svn://localhost/ardour2/branches/3.0@8206 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Paul Davis 2010-12-07 14:45:51 +00:00
parent 0a19ce6f1c
commit e621d704ac
1 changed files with 27 additions and 22 deletions

View File

@ -792,30 +792,35 @@ Editor::add_sources (vector<string> paths, SourceList& sources, framepos_t& pos,
for (vector<boost::shared_ptr<Region> >::iterator r = regions.begin(); r != regions.end(); ++r, ++n) {
boost::shared_ptr<AudioRegion> ar = boost::dynamic_pointer_cast<AudioRegion> (*r);
if (use_timestamp && ar) {
if (use_timestamp) {
if (ar) {
/* get timestamp for this region */
const boost::shared_ptr<Source> s (ar->sources().front());
const boost::shared_ptr<AudioSource> as = boost::dynamic_pointer_cast<AudioSource> (s);
assert (as);
if (as->natural_position() != 0) {
pos = as->natural_position();
} else if (target_tracks == 1) {
/* hmm, no timestamp available, put it after the previous region
*/
if (n == 0) {
pos = get_preferred_edit_position ();
} else {
pos += rlen;
}
} else {
pos = get_preferred_edit_position ();
}
/* get timestamp for this region */
}
const boost::shared_ptr<Source> s (ar->sources().front());
const boost::shared_ptr<AudioSource> as = boost::dynamic_pointer_cast<AudioSource> (s);
assert (as);
if (as->natural_position() != 0) {
pos = as->natural_position();
} else if (target_tracks == 1) {
/* hmm, no timestamp available, put it after the previous region
*/
if (n == 0) {
pos = get_preferred_edit_position ();
} else {
pos += rlen;
}
} else {
pos = get_preferred_edit_position ();
}
} else {
/* should really get first position in MIDI file, but for now, use edit position*/
pos = get_preferred_edit_position ();
}
}
finish_bringing_in_material (*r, input_chan, output_chan, pos, mode, track);