diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc index 724f2dc5d7..43c418d4e4 100644 --- a/gtk2_ardour/editor.cc +++ b/gtk2_ardour/editor.cc @@ -303,6 +303,7 @@ Editor::Editor () , meters_running(false) , _pending_locate_request (false) , _pending_initial_locate (false) + , _last_cut_copy_source_track (0) { constructed = false; diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h index 65395920f1..dd4679012a 100644 --- a/gtk2_ardour/editor.h +++ b/gtk2_ardour/editor.h @@ -2044,6 +2044,11 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD RegionLayeringOrderEditor* layering_order_editor; void update_region_layering_order_editor (ARDOUR::framepos_t); + /** Track that was the source for the last cut/copy operation. Used as a place + to paste things iff there is no selected track. + */ + TimeAxisView* _last_cut_copy_source_track; + friend class Drag; friend class RegionDrag; friend class RegionMoveDrag; diff --git a/gtk2_ardour/editor_ops.cc b/gtk2_ardour/editor_ops.cc index 9f2f29b6d5..12ebeacdd8 100644 --- a/gtk2_ardour/editor_ops.cc +++ b/gtk2_ardour/editor_ops.cc @@ -4213,10 +4213,15 @@ Editor::cut_copy_regions (CutCopyOp op, RegionSelection& rs) foo.push_back ((*i).pl); } - if (!foo.empty()) { cut_buffer->set (foo); } + + if (pmap.empty()) { + _last_cut_copy_source_track = 0; + } else { + _last_cut_copy_source_track = pmap.front().tv; + } for (FreezeList::iterator pl = freezelist.begin(); pl != freezelist.end(); ++pl) { (*pl)->thaw (); @@ -4293,10 +4298,14 @@ Editor::paste_internal (nframes64_t position, float times) /* get everything in the correct order */ if (!selection->tracks.empty()) { + /* there are some selected tracks, so paste to them */ sort_track_selection (); ts = selection->tracks; - } else if (entered_track) { - ts.push_back (entered_track); + } else if (_last_cut_copy_source_track) { + /* otherwise paste to the track that the cut/copy came from; + see discussion in mants #3333. + */ + ts.push_back (_last_cut_copy_source_track); } for (nth = 0, i = ts.begin(); i != ts.end(); ++i, ++nth) {