summaryrefslogtreecommitdiff
path: root/gtk2_ardour/selection.cc
diff options
context:
space:
mode:
authorTim Mayberry <mojofunk@gmail.com>2015-10-28 12:58:55 +1000
committerTim Mayberry <mojofunk@gmail.com>2016-01-14 20:41:44 +1000
commit084af96bf441c065841af6a399d4c0d3c99962d4 (patch)
tree9fbb60b5c005b730c88b2e0d468713d173f70af4 /gtk2_ardour/selection.cc
parentb93a9e26013e8143ff63fcfde1f7c714fff55be3 (diff)
Change handling of Midi note selection to eliminate signal emission/delays.
Each MidiRegionView(MRV) is connected to the Selection::ClearMidiNoteSelection signal that is used to notify the all MRV instances to clear their note selection. The MRV class also has a private static SelectionCleared signal that is used to signal other MRV instances when their selection has been cleared. When the Selection::ClearMidiNoteSelection signal is emitted it causes each MRV to also emit the SelectionCleared signal. So the emission takes quadratic time. With 1500 MRV instances emission takes about 2.2 seconds on my machine, and some operations like track selection cause it to be emitted 3 times(another issue). The Selection class in the Editor knows which MRV instances have note selections, as it is notified by MidiRegionView whenever the selection count becomes zero or becomes non-zero. Clearing the Note selection should then just be O(N) and direct calls can be used rather than signals. This change removes both the signals and uses the existing references between Selection and MRV class to control note selection. There should be no behavioural changes in Midi note selection with this change.
Diffstat (limited to 'gtk2_ardour/selection.cc')
-rw-r--r--gtk2_ardour/selection.cc21
1 files changed, 17 insertions, 4 deletions
diff --git a/gtk2_ardour/selection.cc b/gtk2_ardour/selection.cc
index baf424669f..c1a53bd00d 100644
--- a/gtk2_ardour/selection.cc
+++ b/gtk2_ardour/selection.cc
@@ -27,6 +27,7 @@
#include "ardour/rc_configuration.h"
#include "audio_region_view.h"
+#include "debug.h"
#include "gui_thread.h"
#include "midi_cut_buffer.h"
#include "region_gain_line.h"
@@ -177,9 +178,18 @@ Selection::clear_midi_notes ()
MidiNotesChanged ();
}
- /* The note selection is actually stored in MidiRegionView, emit signal to
- tell them to clear their selection. */
- ClearMidiNoteSelection(); /* EMIT SIGNAL */
+ // clear note selections for MRV's that have note selections
+ // this will cause the MRV to be removed from the list
+ for (MidiRegionSelection::iterator i = midi_regions.begin();
+ i != midi_regions.end();) {
+ MidiRegionSelection::iterator tmp = i;
+ ++tmp;
+ MidiRegionView* mrv = dynamic_cast<MidiRegionView*>(*i);
+ if (mrv) {
+ mrv->clear_selection();
+ }
+ i = tmp;
+ }
}
void
@@ -518,6 +528,8 @@ Selection::add (RegionView* r)
void
Selection::add (MidiRegionView* mrv)
{
+ DEBUG_TRACE(DEBUG::Selection, string_compose("Selection::add MRV %1\n", mrv));
+
clear_time(); //enforce object/range exclusivity
clear_tracks(); //enforce object/track exclusivity
@@ -719,6 +731,8 @@ Selection::remove (RegionView* r)
void
Selection::remove (MidiRegionView* mrv)
{
+ DEBUG_TRACE(DEBUG::Selection, string_compose("Selection::remove MRV %1\n", mrv));
+
MidiRegionSelection::iterator x;
if ((x = find (midi_regions.begin(), midi_regions.end(), mrv)) != midi_regions.end()) {
@@ -727,7 +741,6 @@ Selection::remove (MidiRegionView* mrv)
}
}
-
void
Selection::remove (uint32_t selection_id)
{