From 594f589a6426133fc576ad5903efe7b6818cf4e9 Mon Sep 17 00:00:00 2001 From: Lars Toenning Date: Thu, 13 Jan 2022 22:58:55 +0100 Subject: [PATCH] Issue #134 Fix double free crash on exit The destructor of CThreadedTonePairPlayer was called twice: - after the local stack-variable of CSelcalPlayer got out of scope. - again as part of the CContinuousWorker/DeferredDelete --- src/blacksound/selcalplayer.cpp | 8 ++++---- src/blacksound/selcalplayer.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/blacksound/selcalplayer.cpp b/src/blacksound/selcalplayer.cpp index 9482b71f5..bb0d8ee47 100644 --- a/src/blacksound/selcalplayer.cpp +++ b/src/blacksound/selcalplayer.cpp @@ -18,9 +18,9 @@ namespace BlackSound { CSelcalPlayer::CSelcalPlayer(const CAudioDeviceInfo &device, QObject *parent) : QObject(parent), - m_threadedPlayer(this, "CSelcalPlayer", device) + m_threadedPlayer(new CThreadedTonePairPlayer(this, "CSelcalPlayer", device)) { - m_threadedPlayer.start(); + m_threadedPlayer->start(); } CSelcalPlayer::~CSelcalPlayer() @@ -30,7 +30,7 @@ namespace BlackSound void CSelcalPlayer::gracefulShutdown() { - m_threadedPlayer.quitAndWait(); + m_threadedPlayer->quitAndWait(); } CTime CSelcalPlayer::play(int volume, const CSelcal &selcal) @@ -46,7 +46,7 @@ namespace BlackSound const CTonePair t3(frequencies.at(2), frequencies.at(3), oneSec); QList tonePairs; tonePairs << t1 << t2 << t3; - m_threadedPlayer.play(volume, tonePairs); + m_threadedPlayer->play(volume, tonePairs); duration = oneSec * 2.5; } return duration; diff --git a/src/blacksound/selcalplayer.h b/src/blacksound/selcalplayer.h index 7888134cf..fc42cabde 100644 --- a/src/blacksound/selcalplayer.h +++ b/src/blacksound/selcalplayer.h @@ -40,7 +40,7 @@ namespace BlackSound BlackMisc::PhysicalQuantities::CTime play(int volume, const BlackMisc::Aviation::CSelcal &selcal); private: - CThreadedTonePairPlayer m_threadedPlayer; + CThreadedTonePairPlayer *m_threadedPlayer = nullptr; }; }