13
0

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
This commit is contained in:
Paul Davis 2016-06-02 08:42:58 -04:00
parent 3835b782b3
commit 6baac7d46f
6 changed files with 109 additions and 62 deletions

View File

@ -1409,7 +1409,10 @@ GhostRegion*
AudioRegionView::add_ghost (TimeAxisView& tv)
{
RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*>(&trackview);
assert(rtv);
if (!rtv) {
return 0;
}
double unit_position = _region->position () / samples_per_pixel;
AudioGhostRegion* ghost = new AudioGhostRegion (*this, tv, trackview, unit_position);

View File

@ -200,12 +200,12 @@ AutomationTimeAxisView::AutomationTimeAxisView (
// subscribe to route_active_changed, ...
if (rtv && rtv->is_audio_track()) {
blank0->set_name ("AudioTrackControlsBaseUnselected");
}
else if (rtv && rtv->is_midi_track()) {
} else if (rtv && rtv->is_midi_track()) {
blank0->set_name ("MidiTrackControlsBaseUnselected");
}
else {
} else if (rtv) {
blank0->set_name ("AudioBusControlsBaseUnselected");
} else {
blank0->set_name ("UnknownControlsBaseUnselected");
}
blank0->set_size_request (-1, -1);
blank1->set_size_request (1, 0);

View File

@ -529,7 +529,19 @@ struct PresentationInfoTimeAxisViewSorter {
bool operator() (TimeAxisView* a, TimeAxisView* b) {
RouteTimeAxisView* ra = dynamic_cast<RouteTimeAxisView*> (a);
RouteTimeAxisView* rb = dynamic_cast<RouteTimeAxisView*> (b);
assert (ra && rb);
/* anything not a route goes at the end */
if (!ra && rb) {
return false;
}
if (!rb && ra) {
return true;
}
if (!ra && !rb) {
/* XXXX pointer comparison. Should use
presentation_info in a time axis view
*/
return a < b;
}
return ra->route()->presentation_info () < rb->route()->presentation_info();
}
};
@ -846,7 +858,7 @@ RegionMotionDrag::motion (GdkEvent* event, bool first_move)
RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*> (tv);
if (!rtv || !rtv->is_track()) {
/* ignore busses early on. we can't move any regions on them */
/* ignore non-tracks early on. we can't move any regions on them */
} else if (_last_pointer_time_axis_view < 0) {
/* Was in the drop-zone, now over a track.
* Hence it must be an upward move (from the bottom)

View File

@ -2096,7 +2096,7 @@ Editor::visible_order_range (int* low, int* high) const
RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*> (*i);
if (!rtv->hidden()) {
if (rtv && !rtv->hidden()) {
if (*high < rtv->order()) {
*high = rtv->order ();
@ -2309,7 +2309,7 @@ Editor::mouse_brush_insert_region (RegionView* rv, framepos_t pos)
RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*>(&rv->get_time_axis_view());
if (rtv == 0 || !rtv->is_track()) {
if (!rtv || !rtv->is_track()) {
return;
}

View File

@ -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;
RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*> ((*i));
if ((rtv = dynamic_cast<RouteTimeAxisView*> ((*i))) != 0) {
if (!rtv) {
continue;
}
if (rtv->is_track()) {
if (!rtv->is_track()) {
continue;
}
/* no edits to destructive tracks */
/* no edits to destructive tracks */
if (rtv->track()->destructive()) {
continue;
}
if (rtv->track()->destructive()) {
continue;
}
if ((playlist = rtv->playlist()) != 0) {
if ((playlist = rtv->playlist()) != 0) {
playlist->clear_changes ();
playlist->clear_changes ();
/* XXX need to consider musical time selections here at some point */
/* XXX need to consider musical time selections here at some point */
double speed = rtv->track()->speed();
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;
}
/* pick up changes to existing regions */
vector<Command*> cmds;
playlist->rdiff (cmds);
_session->add_commands (cmds);
/* pick up changes to the playlist itself (adds/removes)
*/
_session->add_command(new StatefulDiffCommand (playlist));
}
if (!in_command) {
begin_reversible_command (_("separate"));
in_command = true;
}
/* pick up changes to existing regions */
vector<Command*> cmds;
playlist->rdiff (cmds);
_session->add_commands (cmds);
/* pick up changes to the playlist itself (adds/removes)
*/
_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));

View File

@ -425,6 +425,11 @@ EditorRoutes::on_tv_rec_enable_changed (std::string const & path_string)
TimeAxisView* tv = row[_columns.tv];
RouteTimeAxisView *rtv = dynamic_cast<RouteTimeAxisView*> (tv);
if (!rtv) {
return;
}
boost::shared_ptr<AutomationControl> ac = rtv->route()->rec_enable_control();
if (ac) {
@ -438,6 +443,11 @@ EditorRoutes::on_tv_rec_safe_toggled (std::string const & path_string)
Gtk::TreeModel::Row row = *_model->get_iter (Gtk::TreeModel::Path (path_string));
TimeAxisView* tv = row[_columns.tv];
RouteTimeAxisView *rtv = dynamic_cast<RouteTimeAxisView*> (tv);
if (!rtv) {
return;
}
boost::shared_ptr<AutomationControl> ac (rtv->route()->rec_safe_control());
if (ac) {
@ -453,6 +463,11 @@ EditorRoutes::on_tv_mute_enable_toggled (std::string const & path_string)
TimeAxisView *tv = row[_columns.tv];
RouteTimeAxisView *rtv = dynamic_cast<RouteTimeAxisView*> (tv);
if (!rtv) {
return;
}
boost::shared_ptr<AutomationControl> ac (rtv->route()->mute_control());
if (ac) {
@ -468,6 +483,11 @@ EditorRoutes::on_tv_solo_enable_toggled (std::string const & path_string)
TimeAxisView *tv = row[_columns.tv];
RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*> (tv);
if (!rtv) {
return;
}
boost::shared_ptr<AutomationControl> ac (rtv->route()->solo_control());
if (ac) {
@ -483,6 +503,11 @@ EditorRoutes::on_tv_solo_isolate_toggled (std::string const & path_string)
TimeAxisView *tv = row[_columns.tv];
RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*> (tv);
if (!rtv) {
return;
}
boost::shared_ptr<AutomationControl> ac (rtv->route()->solo_isolate_control());
if (ac) {
@ -498,6 +523,11 @@ EditorRoutes::on_tv_solo_safe_toggled (std::string const & path_string)
TimeAxisView *tv = row[_columns.tv];
RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*> (tv);
if (!rtv) {
return;
}
boost::shared_ptr<AutomationControl> ac (rtv->route()->solo_safe_control());
if (ac) {