fix crash caused when deleting a region without a playlist PLUS make it impossible...
authorPaul Davis <paul@linuxaudiosystems.com>
Wed, 15 Sep 2010 14:37:08 +0000 (14:37 +0000)
committerPaul Davis <paul@linuxaudiosystems.com>
Wed, 15 Sep 2010 14:37:08 +0000 (14:37 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@7779 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/editor_ops.cc
gtk2_ardour/region_selection.cc
gtk2_ardour/selection.cc

index eac90685078be9531885065c7f23b137c07d2f70..159df414a90f457bd43a809966f67df616b0d73a 100644 (file)
@@ -4144,7 +4144,10 @@ Editor::cut_copy_regions (CutCopyOp op, RegionSelection& rs)
                boost::shared_ptr<Playlist> pl = (*x)->region()->playlist();
 
                if (!pl) {
-                       /* impossible, but this handles it for the future */
+                       /* region not yet associated with a playlist (e.g. unfinished
+                           capture pass.
+                        */
+                        ++x;
                        continue;
                }
 
@@ -4203,8 +4206,10 @@ Editor::cut_copy_regions (CutCopyOp op, RegionSelection& rs)
        /* the pmap is in the same order as the tracks in which selected regions occured */
 
        for (vector<PlaylistMapping>::iterator i = pmap.begin(); i != pmap.end(); ++i) {
-               (*i).pl->thaw();
-               foo.push_back ((*i).pl);
+                if ((*i).pl) {
+                        (*i).pl->thaw();
+                        foo.push_back ((*i).pl);
+                }
        }
 
        if (!foo.empty()) {
index 1a5a556514eabc209fa7238511a001e0bceca5ee..c10888a0864c129e1f4500d2345ef8080f762329 100644 (file)
@@ -98,11 +98,20 @@ bool RegionSelection::contains (RegionView* rv) const
 
 /** Add a region to the selection.
  *  @param rv Region to add.
- *  @return false if we already had the region, otherwise true.
+ *  @return false if we already had the region or if it cannot be added, 
+ *          otherwise true.
  */
 bool
 RegionSelection::add (RegionView* rv)
 {
+        if (!rv->region()->playlist()) {
+                /* not attached to a playlist - selection not allowed.
+                   This happens if the user tries to select a region
+                   during a capture pass.
+                */
+                return false;
+        }
+
        if (contains (rv)) {
                /* we already have it */
                return false;
index 7735993bc18ac9828bca200811382df4e96411ac..886dffb651d8fe5587d755b8c9fad136752ffa84 100644 (file)
@@ -436,11 +436,13 @@ void
 Selection::add (RegionView* r)
 {
        if (find (regions.begin(), regions.end(), r) == regions.end()) {
-               regions.add (r);
-               if (Config->get_link_region_and_track_selection()) {
-                       add (&r->get_time_axis_view());
-               }
-               RegionsChanged ();
+               bool changed = regions.add (r);
+                if (Config->get_link_region_and_track_selection() && changed) {
+                        add (&r->get_time_axis_view());
+                }
+                if (changed) {
+                        RegionsChanged ();
+                }
        }
 }