Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/core/TimePos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,12 @@ TimePos TimePos::quantize(float bars) const
//Offset from the lower position
int offset = m_ticks % interval;
//1 if we should snap up, 0 if we shouldn't
int snapUp = offset / (interval / 2);
// Ternary expression is making sure that the snap happens in the direction to
// the right even if m_ticks is negative and the offset is exactly half-way
// More details on issue #5840 and PR #5847
int snapUp = ((2 * offset) == -interval)
? 0
: (2 * offset) / interval;

return (lowPos + snapUp) * interval;
}
Expand Down
2 changes: 1 addition & 1 deletion src/gui/widgets/TrackContentWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ bool TrackContentWidget::pasteSelection( TimePos tcoPos, const QMimeData * md, b
// All patterns should be offset the same amount as the grabbed pattern
TimePos offset = TimePos(tcoPos - grabbedTCOPos);
// Users expect clips to "fall" backwards, so bias the offset
offset = offset - TimePos::ticksPerBar() * snapSize / 2;
offset -= TimePos::ticksPerBar() * snapSize / 2;
// The offset is quantized (rather than the positions) to preserve fine adjustments
offset = offset.quantize(snapSize);

Expand Down