Remove ghost notes when actual notes are deleted, and ensure the _optimization_iterat...
authorCarl Hetherington <carl@carlh.net>
Thu, 17 Nov 2011 22:15:50 +0000 (22:15 +0000)
committerCarl Hetherington <carl@carlh.net>
Thu, 17 Nov 2011 22:15:50 +0000 (22:15 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@10659 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/ghostregion.cc
gtk2_ardour/ghostregion.h
gtk2_ardour/midi_region_view.cc

index cb4a0d95d3da0a9d09d971e6d5b00481746c9c81..61f0ffcbff7589053f05ce3c1fb915c2aeeb05b5 100644 (file)
@@ -306,6 +306,7 @@ MidiGhostRegion::clear_events()
        }
 
        events.clear();
+       _optimization_iterator = events.end ();
 }
 
 /** Update the x positions of our representation of a parent's note.
@@ -328,13 +329,26 @@ MidiGhostRegion::update_note (ArdourCanvas::CanvasNote* parent)
        }
 }
 
+void
+MidiGhostRegion::remove_note (ArdourCanvas::CanvasNoteEvent* note)
+{
+       Event* ev = find_event (note);
+       if (!ev) {
+               return;
+       }
+
+       events.remove (ev);
+       delete ev;
+       _optimization_iterator = events.end ();
+}
+
 /** Given a note in our parent region (ie the actual MidiRegionView), find our
  *  representation of it.
  *  @return Our Event, or 0 if not found.
  */
 
 MidiGhostRegion::Event *
-MidiGhostRegion::find_event (ArdourCanvas::CanvasNote* parent)
+MidiGhostRegion::find_event (ArdourCanvas::CanvasNoteEvent* parent)
 {
        /* we are using _optimization_iterator to speed up the common case where a caller
           is going through our notes in order.
index 103d7ecf97bacb26aba2e87327f609344385746d..50924619ff6eaf7682c925b2a15a53f2cd1072ac 100644 (file)
@@ -105,12 +105,13 @@ public:
 
        void add_note(ArdourCanvas::CanvasNote*);
        void update_note (ArdourCanvas::CanvasNote *);
+       void remove_note (ArdourCanvas::CanvasNoteEvent *);
 
        void clear_events();
 
 private:
 
-       MidiGhostRegion::Event* find_event (ArdourCanvas::CanvasNote *);
+       MidiGhostRegion::Event* find_event (ArdourCanvas::CanvasNoteEvent *);
 
        typedef std::list<MidiGhostRegion::Event*> EventList;
        EventList events;
index 6bb1eb98e7e317683069fce6866231e108a0a930..00bdb94dce74911508c11846a94b7a0811c3cd2c 100644 (file)
@@ -1156,8 +1156,17 @@ MidiRegionView::redisplay_model()
 
        for (Events::iterator i = _events.begin(); i != _events.end(); ) {
                if (!(*i)->valid ()) {
+
+                       for (vector<GhostRegion*>::iterator j = ghosts.begin(); j != ghosts.end(); ++j) {
+                               MidiGhostRegion* gr = dynamic_cast<MidiGhostRegion*> (*j);
+                               if (gr) {
+                                       gr->remove_note (*i);
+                               }
+                       }
+                       
                        delete *i;
                        i = _events.erase (i);
+                       
                } else {
                        ++i;
                }