diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc index a044f2ad91..9c431fdd2c 100644 --- a/gtk2_ardour/editor.cc +++ b/gtk2_ardour/editor.cc @@ -304,6 +304,8 @@ Editor::Editor () , _pending_locate_request (false) , _pending_initial_locate (false) , _last_cut_copy_source_track (0) + + , _block_region_list_update_if_empty (false) { constructed = false; diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h index 390b94664b..e47946499d 100644 --- a/gtk2_ardour/editor.h +++ b/gtk2_ardour/editor.h @@ -2047,6 +2047,11 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD */ TimeAxisView* _last_cut_copy_source_track; + /** true if the update of the region list's selection from the current Selection + should be blocked if the Selection is empty. See EditorRegions::selection_changed. + */ + bool _block_region_list_update_if_empty; + friend class Drag; friend class RegionDrag; friend class RegionMoveDrag; diff --git a/gtk2_ardour/editor_regions.cc b/gtk2_ardour/editor_regions.cc index 9fc2a70663..7034a76af1 100644 --- a/gtk2_ardour/editor_regions.cc +++ b/gtk2_ardour/editor_regions.cc @@ -377,6 +377,13 @@ EditorRegions::selection_changed () return; } + /* We may have selected a region which is not displayed in the Editor. If this happens, the + result will be no selected regions in the editor's Selection. Without the following line, + this `no-selection' will be mapped back to our list, meaning that the selection will + appear not to take. + */ + _editor->_block_region_list_update_if_empty = true; + if (_display.get_selection()->count_selected_rows() > 0) { TreeIter iter; @@ -409,6 +416,8 @@ EditorRegions::selection_changed () } else { _editor->get_selection().clear_regions (); } + + _editor->_block_region_list_update_if_empty = false; } void diff --git a/gtk2_ardour/editor_selection.cc b/gtk2_ardour/editor_selection.cc index d17d230cf8..5c0a300322 100644 --- a/gtk2_ardour/editor_selection.cc +++ b/gtk2_ardour/editor_selection.cc @@ -957,7 +957,9 @@ Editor::region_selection_changed () _regions->block_change_connection (true); editor_regions_selection_changed_connection.block(true); - _regions->unselect_all (); + if (!_block_region_list_update_if_empty || !selection->regions.empty()) { + _regions->unselect_all (); + } for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) { (*i)->set_selected_regionviews (selection->regions);