Fix reference of track after free() (#4795).
[ardour.git] / gtk2_ardour / region_selection.cc
index 333e2104ad8f49244affffc5883c939f162ad763..127a0ffe8e055f9356cddb6a72cfb634b263c677 100644 (file)
@@ -269,8 +269,20 @@ RegionSelection::end_frame () const
 {
        framepos_t e = 0;
        for (RegionSelection::const_iterator i = begin(); i != end(); ++i) {
-               e = max (e, (*i)->region()->position () + (*i)->region()->length ());
+               e = max (e, (*i)->region()->last_frame ());
        }
 
        return e;
 }
+
+/** @return the playlists that the regions in the selection are on */
+set<boost::shared_ptr<Playlist> >
+RegionSelection::playlists () const
+{
+       set<boost::shared_ptr<Playlist> > pl;
+       for (RegionSelection::const_iterator i = begin(); i != end(); ++i) {
+               pl.insert ((*i)->region()->playlist ());
+       }
+
+       return pl;
+}