Replace static PBD::Signal in NoteBase with direct call to MidiRegionView
authorTim Mayberry <mojofunk@gmail.com>
Wed, 14 Oct 2015 10:37:07 +0000 (20:37 +1000)
committerPaul Davis <paul@linuxaudiosystems.com>
Sun, 18 Oct 2015 02:15:07 +0000 (22:15 -0400)
NoteBaseDeleted signal is static so each MidiRegionView(MRV) gets notified
about the deletion of each NodeBase instance even if it is contained in another
MRV

The NoteBase and MRV classes are currently coupled anyway, so this change uses
the reference to the MRV parent to directly call the parent when the NoteBase
is deleted. This is all in the GUI thread so I'm not sure why a PBD::Signal was
being used?

If the MRV class is the only reference holder to the NoteBase class
then I'm not sure if a callback is needed, perhaps the MRV should just remove
the note from the selection before deleting it but I'm not that familiar with
the code.

Signal emission/calls static NoteBaseDeleted signal vs direct with 10540
NoteBase instances.

static:

After Load Session: 6360638
After Unload Session: 12221026(5860388)

direct:

After load Session: 10540
After unload Session: 21080

Session Load/Unload time in master, debug/release with ~10000 Notes(seconds)

Load Debug: 32, 26
Unload Debug: 83
Load Release 32, 20, 42
Unload Release 26, 25

Session Load/Unload time with direct call debug/release(seconds)

Load Debug: 21.7, 18.1
Unload Debug: 69.4, 71
Load Release: 22.6, 13.4, 17.7
Unload Release: 24, 23.5

This is not a large Session, 1500 regions, 10000 notes so there is probably
some other funky stuff going on that needs fixing.

gtk2_ardour/midi_region_view.cc
gtk2_ardour/midi_region_view.h
gtk2_ardour/note_base.cc
gtk2_ardour/note_base.h

index 5300a825743e46b8467d17d690f1a0ca87a105e6..682f02365c89400dceeab8d1a44616d8f86e7e10 100644 (file)
@@ -268,10 +268,6 @@ MidiRegionView::init (bool wfd)
 {
        PublicEditor::DropDownKeys.connect (sigc::mem_fun (*this, &MidiRegionView::drop_down_keys));
 
-       NoteBase::NoteBaseDeleted.connect (note_delete_connection, MISSING_INVALIDATOR,
-                                          boost::bind (&MidiRegionView::maybe_remove_deleted_note_from_selection, this, _1),
-                                          gui_context());
-
        if (wfd) {
                Glib::Threads::Mutex::Lock lm(midi_region()->midi_source(0)->mutex());
                midi_region()->midi_source(0)->load_model(lm);
@@ -1384,8 +1380,6 @@ MidiRegionView::~MidiRegionView ()
 
        hide_verbose_cursor ();
 
-       note_delete_connection.disconnect ();
-
        delete _list_editor;
 
        RegionViewGoingAway (this); /* EMIT_SIGNAL */
@@ -2098,7 +2092,7 @@ MidiRegionView::step_patch (PatchChange& patch, bool bank, int delta)
 }
 
 void
-MidiRegionView::maybe_remove_deleted_note_from_selection (NoteBase* cne)
+MidiRegionView::note_deleted (NoteBase* cne)
 {
        if (_selection.empty()) {
                return;
index 786a7ec7c45cefdc5bb7b85e574e038f74548a22..05d5df98f944b42c8dea65b4aa5226c9cdd086b4 100644 (file)
@@ -332,6 +332,8 @@ public:
 
         ARDOUR::InstrumentInfo& instrument_info() const;
 
+       void note_deleted (NoteBase*);
+
 protected:
        void region_resized (const PBD::PropertyChange&);
 
@@ -471,9 +473,6 @@ private:
        MidiListEditor* _list_editor;
        bool _no_sound_notes;
 
-       PBD::ScopedConnection note_delete_connection;
-       void maybe_remove_deleted_note_from_selection (NoteBase*);
-
        void snap_changed ();
        PBD::ScopedConnection snap_changed_connection;
 
index 228a6dead7235f38940dea8701de6b504acef954..feee7e7d7c09503a86683eaeffd35da0ff9c5980 100644 (file)
@@ -36,8 +36,6 @@ using namespace Gtkmm2ext;
 using ARDOUR::MidiModel;
 using namespace ArdourCanvas;
 
-PBD::Signal1<void,NoteBase*> NoteBase::NoteBaseDeleted;
-
 /// dividing the hue circle in 16 parts, hand adjusted for equal look, courtesy Thorsten Wilms
 const uint32_t NoteBase::midi_channel_colors[16] = {
          0xd32d2dff,  0xd36b2dff,  0xd3972dff,  0xd3d12dff,
@@ -62,7 +60,7 @@ NoteBase::NoteBase(MidiRegionView& region, bool with_events, const boost::shared
 
 NoteBase::~NoteBase()
 {
-       NoteBaseDeleted (this);
+       _region.note_deleted (this);
 
        delete _text;
 }
index e63e59b84b2326c04b7e299f297606b103a0b2c1..1e94e709a37de57605a10f33ec39ffd55b01c932 100644 (file)
@@ -61,8 +61,6 @@ class NoteBase : public sigc::trackable
        void set_item (ArdourCanvas::Item *);
         ArdourCanvas::Item* item() const { return _item; }
 
-        static PBD::Signal1<void, NoteBase*> NoteBaseDeleted;
-
        virtual void show() = 0;
        virtual void hide() = 0;