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.
This commit is contained in:
parent
5d02970de8
commit
0f4fb04344
@ -6201,11 +6201,16 @@ NoteDrag::total_dx (GdkEvent* event) const
|
|||||||
timepos_t const t2 = pixel_to_time (grab_x ());
|
timepos_t const t2 = pixel_to_time (grab_x ());
|
||||||
|
|
||||||
/* now calculate proper `b@b` time */
|
/* 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 */
|
/* primary note time in quarter notes */
|
||||||
timepos_t const n_qn = _region->region ()->source_beats_to_absolute_time (_primary->note ()->time ());
|
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)
|
/* new session relative time of the primary note (will be in beats)
|
||||||
|
|
||||||
* start from the note position, add the distance the drag has covered,
|
* start from the note position, add the distance the drag has covered,
|
||||||
|
Loading…
Reference in New Issue
Block a user