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
This commit is contained in:
Lars Toenning
2022-01-13 22:58:55 +01:00
committed by Mat Sutcliffe
parent 154a1c803f
commit 594f589a64
2 changed files with 5 additions and 5 deletions

View File

@@ -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<CTonePair> tonePairs;
tonePairs << t1 << t2 << t3;
m_threadedPlayer.play(volume, tonePairs);
m_threadedPlayer->play(volume, tonePairs);
duration = oneSec * 2.5;
}
return duration;

View File

@@ -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;
};
}