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;
}
/* 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()) {
/** 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;
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 ();
+ }
}
}