Fix crashes after removing markers.
authorCarl Hetherington <carl@carlh.net>
Sun, 14 Nov 2010 23:47:09 +0000 (23:47 +0000)
committerCarl Hetherington <carl@carlh.net>
Sun, 14 Nov 2010 23:47:09 +0000 (23:47 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@8039 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/editor.h
gtk2_ardour/editor_markers.cc

index a8c5fa3db5606c87aed8e8981a930021374aba09..2b08569220442d211b1796315b4e177e3484c753 100644 (file)
@@ -637,6 +637,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
         *  for all markers or for just a few.
         */
        std::map<ArdourCanvas::Group *, std::list<Marker *> > _sorted_marker_lists;
+       void remove_sorted_marker (Marker *);
 
        void hide_marker (ArdourCanvas::Item*, GdkEvent*);
        void clear_marker_display ();
index 3f9c65a4c2a6b7851f418731cc142d4d019333db..78c1edb8b0b4428dcd7c9d0c2ab06aceebe2eac5 100644 (file)
@@ -55,6 +55,7 @@ Editor::clear_marker_display ()
        }
 
        location_markers.clear ();
+       _sorted_marker_lists.clear ();
 }
 
 void
@@ -495,6 +496,12 @@ Editor::refresh_location_display_internal (Locations::LocationList& locations)
                ++tmp;
 
                if (!i->second->valid) {
+
+                       remove_sorted_marker (i->second->start);
+                       if (i->second->end) {
+                               remove_sorted_marker (i->second->end);
+                       }
+                       
                        delete i->second;
                        location_markers.erase (i);
                }
@@ -699,8 +706,15 @@ Editor::location_gone (Location *location)
        }
 
        for (i = location_markers.begin(); i != location_markers.end(); ++i) {
-               if ((*i).first == location) {
-                       delete (*i).second;
+               if (i->first == location) {
+
+                       remove_sorted_marker (i->second->start);
+                       if (i->second->end) {
+                               remove_sorted_marker (i->second->end);
+                       }
+                       
+                       
+                       delete i->second;
                        location_markers.erase (i);
                        break;
                }
@@ -1496,3 +1510,11 @@ Editor::toggle_marker_lines ()
                i->second->set_show_lines (_show_marker_lines);
        }
 }
+
+void
+Editor::remove_sorted_marker (Marker* m)
+{
+       for (std::map<ArdourCanvas::Group *, std::list<Marker *> >::iterator i = _sorted_marker_lists.begin(); i != _sorted_marker_lists.end(); ++i) {
+               i->second.remove (m);
+       }
+}