From ccff7d617acb3644c7695e87959751dd72366007 Mon Sep 17 00:00:00 2001 From: Shmuel H Date: Sun, 19 May 2019 11:08:39 +0300 Subject: [PATCH] SampleTrack: call requestChangesInModel before unref SampleBuffer To avoid a race condition between the gui thread which destroys the samplebuffer and the mixer thread which increases the buffer's ref- count, we'll make sure to touch the ref-count only when whe're synced with the mixer. --- src/tracks/SampleTrack.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/tracks/SampleTrack.cpp b/src/tracks/SampleTrack.cpp index faf066e8d72..bd656572c08 100644 --- a/src/tracks/SampleTrack.cpp +++ b/src/tracks/SampleTrack.cpp @@ -110,7 +110,9 @@ SampleTCO::~SampleTCO() { sampletrack->updateTcos(); } + Engine::mixer()->requestChangeInModel(); sharedObject::unref( m_sampleBuffer ); + Engine::mixer()->doneChangeInModel(); } @@ -133,7 +135,9 @@ const QString & SampleTCO::sampleFile() const void SampleTCO::setSampleBuffer( SampleBuffer* sb ) { - sharedObject::unref( m_sampleBuffer ); + Engine::mixer()->requestChangeInModel(); + sharedObject::unref( m_sampleBuffer ); + Engine::mixer()->doneChangeInModel(); m_sampleBuffer = sb; updateLength();