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

@ -3043,11 +3043,15 @@ 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 */
@ -3063,7 +3067,6 @@ Editor::separate_regions_between (const TimeSelection& ts)
double speed = rtv->track()->speed();
for (list<AudioRange>::const_iterator t = ts.begin(); t != ts.end(); ++t) {
sigc::connection c = rtv->view()->RegionViewAdded.connect (
@ -3101,8 +3104,6 @@ Editor::separate_regions_between (const TimeSelection& ts)
}
}
}
}
}
if (in_command) {
// selection->set (new_selection);
@ -3293,9 +3294,11 @@ 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();
@ -3306,7 +3309,6 @@ Editor::crop_region_to (framepos_t start, framepos_t end)
}
}
}
}
if (playlists.empty()) {
return;
@ -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;
}

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) {