From e621d704ac16f7da143a1c7ab3d6864c803ec8c9 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Tue, 7 Dec 2010 14:45:51 +0000 Subject: fix crash when importing MIDI with "at timestamp" chosen git-svn-id: svn://localhost/ardour2/branches/3.0@8206 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/editor_audio_import.cc | 49 +++++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 22 deletions(-) (limited to 'gtk2_ardour/editor_audio_import.cc') diff --git a/gtk2_ardour/editor_audio_import.cc b/gtk2_ardour/editor_audio_import.cc index 38355e964d..8ed6248cf1 100644 --- a/gtk2_ardour/editor_audio_import.cc +++ b/gtk2_ardour/editor_audio_import.cc @@ -792,30 +792,35 @@ Editor::add_sources (vector paths, SourceList& sources, framepos_t& pos, for (vector >::iterator r = regions.begin(); r != regions.end(); ++r, ++n) { boost::shared_ptr ar = boost::dynamic_pointer_cast (*r); - if (use_timestamp && ar) { + if (use_timestamp) { + if (ar) { - /* get timestamp for this region */ - - const boost::shared_ptr s (ar->sources().front()); - const boost::shared_ptr as = boost::dynamic_pointer_cast (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 s (ar->sources().front()); + const boost::shared_ptr as = boost::dynamic_pointer_cast (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); -- cgit v1.2.3