From 9c6e2278cef8e8da2edcbe74d95e7b334a0bd9b8 Mon Sep 17 00:00:00 2001 From: Shmuel H Date: Mon, 27 May 2019 21:26:30 +0300 Subject: [PATCH] SampleTrack: call requestChangesInModel before unref SampleBuffer (#4982) 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 wh're synced with the mixer. --- src/tracks/SampleTrack.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/tracks/SampleTrack.cpp b/src/tracks/SampleTrack.cpp index faf066e8d72..b45f442d17b 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 ) { + Engine::mixer()->requestChangeInModel(); sharedObject::unref( m_sampleBuffer ); + Engine::mixer()->doneChangeInModel(); m_sampleBuffer = sb; updateLength();