Skip to content

Commit

Permalink
Fixed crash caused by that a manually adjusted sustain section was al…
Browse files Browse the repository at this point in the history
…lowed to be invalid.
  • Loading branch information
larspalo committed Sep 8, 2024
1 parent de95179 commit bbf77ee
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Bug that could cause a crash when trying to auto detect sustain section.
- Regression in LoopOverlay dialog that didn't take size changes into account for adjusting max number of samples to display.
- Bug that could cause a crash when adjusting sustain section on waveform manually.

## [0.11.0] - 2024-06-19

Expand Down
22 changes: 15 additions & 7 deletions src/WaveformDrawer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -712,18 +712,26 @@ void WaveformDrawer::OnMouseMotion(wxMouseEvent& WXUNUSED(event)) {
m_sustainsection_rect.xExtent += (m_prev_x - mouseX);
m_sustainsection_rect.xPosLeft -= (m_prev_x - mouseX);
outlineHasChanged = true;
} else if (mouseX > m_prev_x && m_sustainsection_rect.xPosLeft < (m_sustainsection_rect.xPosLeft + m_sustainsection_rect.xExtent - 5)) {
m_sustainsection_rect.xExtent -= (mouseX - m_prev_x);
m_sustainsection_rect.xPosLeft += (mouseX - m_prev_x);
outlineHasChanged = true;
} else if (mouseX > m_prev_x && ((double) m_sustainsection_rect.xExtent / trackWidth * 100 + 0.5 > 1.0f)) {
if ((m_sustainsection_rect.xExtent - (mouseX - m_prev_x)) / (double) trackWidth * 100 + 0.5 > 1.0f) {
m_sustainsection_rect.xExtent -= (mouseX - m_prev_x);
m_sustainsection_rect.xPosLeft += (mouseX - m_prev_x);
outlineHasChanged = true;
} else {
outlineHasChanged = false;
}
} else {
outlineHasChanged = false;
}
m_prev_x = mouseX;
} else if (withinRightChangeBorder) {
if (mouseX < m_prev_x && (m_sustainsection_rect.xPosLeft + m_sustainsection_rect.xExtent) > (m_sustainsection_rect.xPosLeft + 4)) {
m_sustainsection_rect.xExtent -= (m_prev_x - mouseX);
outlineHasChanged = true;
if (mouseX < m_prev_x && (m_sustainsection_rect.xExtent / (double) trackWidth * 100 > 1.0f)) {
if ((m_sustainsection_rect.xExtent - (m_prev_x - mouseX)) / (double) trackWidth * 100 > 1.0f) {
m_sustainsection_rect.xExtent -= (m_prev_x - mouseX);
outlineHasChanged = true;
} else {
outlineHasChanged = false;
}
} else if (mouseX > m_prev_x && (m_sustainsection_rect.xPosLeft + m_sustainsection_rect.xExtent) < (leftMargin + trackWidth)) {
m_sustainsection_rect.xExtent += (mouseX - m_prev_x);
outlineHasChanged = true;
Expand Down

0 comments on commit bbf77ee

Please sign in to comment.