From 0f4fb043446629cf228238ac1e3740ffd4f83687 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Fri, 2 Aug 2024 17:53:26 +0200 Subject: [PATCH] Prevent crash when dragging notes near 1|0|0 When moving the mouse fast it can happen that the resulting position (note_qn + dx) becomes negative. Which causes tempo-map ramp calculations to fail and the application aborts. --- gtk2_ardour/editor_drag.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/gtk2_ardour/editor_drag.cc b/gtk2_ardour/editor_drag.cc index 39296bac62..5ea7bf8dfc 100644 --- a/gtk2_ardour/editor_drag.cc +++ b/gtk2_ardour/editor_drag.cc @@ -6201,11 +6201,16 @@ NoteDrag::total_dx (GdkEvent* event) const timepos_t const t2 = pixel_to_time (grab_x ()); /* now calculate proper `b@b` time */ - timecnt_t const dx = t2.distance (t1); + timecnt_t dx = t2.distance (t1); /* primary note time in quarter notes */ timepos_t const n_qn = _region->region ()->source_beats_to_absolute_time (_primary->note ()->time ()); + /* prevent (n_qn + dx) from becoming negative */ + if (-dx.distance() > timecnt_t(n_qn).distance ()) { + dx = n_qn.distance (timepos_t (0)); + } + /* new session relative time of the primary note (will be in beats) * start from the note position, add the distance the drag has covered,