From bad57356d73c2ebfc147863a54e052fe83fe94a6 Mon Sep 17 00:00:00 2001 From: saker Date: Fri, 29 Mar 2024 12:36:20 -0400 Subject: [PATCH] Fix infinite loop in `InstrumentPlayHandle::play` (#7176) --- src/core/InstrumentPlayHandle.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/core/InstrumentPlayHandle.cpp b/src/core/InstrumentPlayHandle.cpp index 06b8837a8..ef7d78f3f 100644 --- a/src/core/InstrumentPlayHandle.cpp +++ b/src/core/InstrumentPlayHandle.cpp @@ -47,22 +47,21 @@ void InstrumentPlayHandle::play(sampleFrame * working_buffer) // ensure that all our nph's have been processed first auto nphv = NotePlayHandle::nphsOfInstrumentTrack(instrumentTrack, true); - bool nphsLeft = false; + bool nphsLeft; do { - for (const NotePlayHandle * constNotePlayHandle : nphv) + nphsLeft = false; + for (const auto& handle : nphv) { - if (constNotePlayHandle->state() != ThreadableJob::ProcessingState::Done && - !constNotePlayHandle->isFinished()) + if (handle->state() != ThreadableJob::ProcessingState::Done && !handle->isFinished()) { nphsLeft = true; - NotePlayHandle * notePlayHandle = const_cast(constNotePlayHandle); - notePlayHandle->process(); + const_cast(handle)->process(); } } } while (nphsLeft); - + m_instrument->play(working_buffer); // Process the audio buffer that the instrument has just worked on...