lmms icon indicating copy to clipboard operation
lmms copied to clipboard

Clean up computation of "from" and "to" values in AudioFileProcessorWaveView

Open michaelgregorius opened this issue 2 years ago • 0 comments

Pull request #7071 has fixed a crash that was reported in #7068 by adding safety checks via two new setter methods in plugins/AudioFileProcessor/AudioFileProcessorWaveView.h.

While the crash is gone there is still code that tries to set the "from" and "to" values to invalid values. One such method is AudioFileProcessorWaveView::slide. To fix this adjust the two new setters as follows:

void AudioFileProcessorWaveView::setTo(f_cnt_t to)
{
	assert (to <= m_sample->sampleSize());
	m_to = std::min(to, static_cast<lmms::f_cnt_t>(m_sample->sampleSize()));
}

void AudioFileProcessorWaveView::setFrom(f_cnt_t from)
{
	assert (from >= 0);
	m_from = std::max(from, 0);
}

Then follow these steps:

  1. Add an AFP and open it's view.
  2. Drag a sample onto the sample view of the AFP, e.g. drums/clap01.ogg from the factory samples.
  3. Click with the left mouse button on the sample display and drag to the right until the crash occurs.

michaelgregorius avatar Jan 24 '24 17:01 michaelgregorius