summaryrefslogtreecommitdiff
path: root/gtk2_ardour/editor_ops.cc
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2016-06-02 08:42:58 -0400
committerPaul Davis <paul@linuxaudiosystems.com>2016-06-02 08:42:58 -0400
commit6baac7d46f95cfe94eb1a67f64a2a68f0cf4552d (patch)
tree81c71bbffc6a47350725b670022863ec759a4763 /gtk2_ardour/editor_ops.cc
parent3835b782b370940ba1c96bcb212338e86e30e590 (diff)
various safety checks for the result of dynamic_cast-ing a TimeAxisView to RouteTimeAxisView
Now that we have VCATimeAxisView, this needed to be done, but it also potentially applied with automation
Diffstat (limited to 'gtk2_ardour/editor_ops.cc')
-rw-r--r--gtk2_ardour/editor_ops.cc102
1 files changed, 52 insertions, 50 deletions
diff --git a/gtk2_ardour/editor_ops.cc b/gtk2_ardour/editor_ops.cc
index d05b183028..ccb77558b8 100644
--- a/gtk2_ardour/editor_ops.cc
+++ b/gtk2_ardour/editor_ops.cc
@@ -2574,7 +2574,7 @@ Editor::play_from_edit_point_and_return ()
void
Editor::play_selection ()
{
- framepos_t start, end;
+ framepos_t start, end;
if (!get_selection_extents ( start, end))
return;
@@ -3043,62 +3043,63 @@ Editor::separate_regions_between (const TimeSelection& ts)
for (TrackSelection::iterator i = tmptracks.begin(); i != tmptracks.end(); ++i) {
- RouteTimeAxisView* rtv;
-
- if ((rtv = dynamic_cast<RouteTimeAxisView*> ((*i))) != 0) {
+ RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*> ((*i));
- if (rtv->is_track()) {
+ if (!rtv) {
+ continue;
+ }
- /* no edits to destructive tracks */
+ if (!rtv->is_track()) {
+ continue;
+ }
- if (rtv->track()->destructive()) {
- continue;
- }
+ /* no edits to destructive tracks */
- if ((playlist = rtv->playlist()) != 0) {
+ if (rtv->track()->destructive()) {
+ continue;
+ }
- playlist->clear_changes ();
+ if ((playlist = rtv->playlist()) != 0) {
- /* XXX need to consider musical time selections here at some point */
+ playlist->clear_changes ();
- double speed = rtv->track()->speed();
+ /* XXX need to consider musical time selections here at some point */
+ double speed = rtv->track()->speed();
- for (list<AudioRange>::const_iterator t = ts.begin(); t != ts.end(); ++t) {
+ for (list<AudioRange>::const_iterator t = ts.begin(); t != ts.end(); ++t) {
- sigc::connection c = rtv->view()->RegionViewAdded.connect (
- sigc::mem_fun(*this, &Editor::collect_new_region_view));
+ sigc::connection c = rtv->view()->RegionViewAdded.connect (
+ sigc::mem_fun(*this, &Editor::collect_new_region_view));
- latest_regionviews.clear ();
+ latest_regionviews.clear ();
- playlist->partition ((framepos_t)((*t).start * speed),
- (framepos_t)((*t).end * speed), false);
+ playlist->partition ((framepos_t)((*t).start * speed),
+ (framepos_t)((*t).end * speed), false);
- c.disconnect ();
+ c.disconnect ();
- if (!latest_regionviews.empty()) {
+ if (!latest_regionviews.empty()) {
- rtv->view()->foreach_regionview (sigc::bind (
- sigc::ptr_fun (add_if_covered),
- &(*t), &new_selection));
+ rtv->view()->foreach_regionview (sigc::bind (
+ sigc::ptr_fun (add_if_covered),
+ &(*t), &new_selection));
- if (!in_command) {
- begin_reversible_command (_("separate"));
- in_command = true;
- }
+ if (!in_command) {
+ begin_reversible_command (_("separate"));
+ in_command = true;
+ }
- /* pick up changes to existing regions */
+ /* pick up changes to existing regions */
- vector<Command*> cmds;
- playlist->rdiff (cmds);
- _session->add_commands (cmds);
+ vector<Command*> cmds;
+ playlist->rdiff (cmds);
+ _session->add_commands (cmds);
- /* pick up changes to the playlist itself (adds/removes)
- */
+ /* pick up changes to the playlist itself (adds/removes)
+ */
- _session->add_command(new StatefulDiffCommand (playlist));
- }
- }
+ _session->add_command(new StatefulDiffCommand (playlist));
}
}
}
@@ -3218,7 +3219,7 @@ Editor::separate_under_selected_regions ()
if (!playlist) {
// is this check necessary?
- continue;
+ continue;
}
vector<PlaylistState>::iterator i;
@@ -3293,17 +3294,18 @@ Editor::crop_region_to (framepos_t start, framepos_t end)
for (TrackSelection::iterator i = ts.begin(); i != ts.end(); ++i) {
- RouteTimeAxisView* rtv;
+ RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*> ((*i));
- if ((rtv = dynamic_cast<RouteTimeAxisView*> ((*i))) != 0) {
+ if (!rtv) {
+ continue;
+ }
- boost::shared_ptr<Track> t = rtv->track();
+ boost::shared_ptr<Track> t = rtv->track();
- if (t != 0 && ! t->destructive()) {
+ if (t != 0 && ! t->destructive()) {
- if ((playlist = rtv->playlist()) != 0) {
- playlists.push_back (playlist);
- }
+ if ((playlist = rtv->playlist()) != 0) {
+ playlists.push_back (playlist);
}
}
}
@@ -3392,7 +3394,7 @@ Editor::region_fill_track ()
sigc::connection c = rtv->view()->RegionViewAdded.connect (sigc::mem_fun(*this, &Editor::collect_new_region_view));
framepos_t const position = end_frame + (r->first_frame() - start_frame + 1);
- playlist = (*i)->region()->playlist();
+ playlist = (*i)->region()->playlist();
playlist->clear_changes ();
playlist->duplicate_until (r, position, gap, end);
_session->add_command(new StatefulDiffCommand (playlist));
@@ -3957,9 +3959,9 @@ Editor::bounce_range_selection (bool replace, bool enable_processing)
for (TrackViewList::iterator i = views.begin(); i != views.end(); ++i) {
- RouteTimeAxisView* rtv;
+ RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*> (*i);
- if ((rtv = dynamic_cast<RouteTimeAxisView*> (*i)) == 0) {
+ if (!rtv) {
continue;
}
@@ -4384,7 +4386,7 @@ Editor::remove_selected_regions ()
if (!playlist) {
// is this check necessary?
- continue;
+ continue;
}
/* get_regions_from_selection_and_entered() guarantees that
@@ -4788,7 +4790,7 @@ Editor::duplicate_some_regions (RegionSelection& regions, float times)
sigc::connection c = rtv->view()->RegionViewAdded.connect (sigc::mem_fun(*this, &Editor::collect_new_region_view));
framepos_t const position = end_frame + (r->first_frame() - start_frame + 1);
- playlist = (*i)->region()->playlist();
+ playlist = (*i)->region()->playlist();
playlist->clear_changes ();
playlist->duplicate (r, position, gap, times);
_session->add_command(new StatefulDiffCommand (playlist));