From b929eb442ae46159e177d20ffb22f48e917dfc4d Mon Sep 17 00:00:00 2001 From: Mat Sutcliffe Date: Thu, 10 Oct 2019 20:46:35 +0100 Subject: [PATCH] [AFV] CContextAudio::m_voiceClient is a raw pointer, and CAfvClient doesn't have a parent --- src/blackcore/afv/clients/afvclient.cpp | 4 ++-- src/blackcore/afv/clients/afvclient.h | 2 +- src/blackcore/context/contextaudio.cpp | 13 +++++++------ src/blackcore/context/contextaudio.h | 2 +- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/blackcore/afv/clients/afvclient.cpp b/src/blackcore/afv/clients/afvclient.cpp index d5df9911c..3a49bc824 100644 --- a/src/blackcore/afv/clients/afvclient.cpp +++ b/src/blackcore/afv/clients/afvclient.cpp @@ -38,8 +38,8 @@ namespace BlackCore return cats; } - CAfvClient::CAfvClient(const QString &apiServer, QObject *parent) : - CContinuousWorker(parent, "CAfvClient"), + CAfvClient::CAfvClient(const QString &apiServer, QObject *owner) : + CContinuousWorker(owner, "CAfvClient"), m_connection(new CClientConnection(apiServer, this)), m_input(new CInput(SampleRate, this)), m_output(new Output(this)), diff --git a/src/blackcore/afv/clients/afvclient.h b/src/blackcore/afv/clients/afvclient.h index 7dbb89564..79403c1c2 100644 --- a/src/blackcore/afv/clients/afvclient.h +++ b/src/blackcore/afv/clients/afvclient.h @@ -63,7 +63,7 @@ namespace BlackCore Q_ENUM(ConnectionStatus) //! Ctor - CAfvClient(const QString &apiServer, QObject *parent = nullptr); + CAfvClient(const QString &apiServer, QObject *owner); //! Dtor virtual ~CAfvClient() override { this->stopAudio(); } diff --git a/src/blackcore/context/contextaudio.cpp b/src/blackcore/context/contextaudio.cpp index b18810a65..8a63f1e27 100644 --- a/src/blackcore/context/contextaudio.cpp +++ b/src/blackcore/context/contextaudio.cpp @@ -46,11 +46,11 @@ namespace BlackCore Q_ASSERT_X(m_voiceClient->owner() == this, Q_FUNC_INFO, "Wrong owner"); Q_ASSERT_X(!CThreadUtils::isApplicationThread(m_voiceClient->thread()), Q_FUNC_INFO, "Must NOT be in main thread"); - connect(m_voiceClient.get(), &CAfvClient::outputVolumePeakVU, this, &IContextAudio::outputVolumePeakVU); - connect(m_voiceClient.get(), &CAfvClient::inputVolumePeakVU, this, &IContextAudio::inputVolumePeakVU); - connect(m_voiceClient.get(), &CAfvClient::receivingCallsignsChanged, this, &IContextAudio::receivingCallsignsChanged); - connect(m_voiceClient.get(), &CAfvClient::updatedFromOwnAircraftCockpit, this, &IContextAudio::updatedFromOwnAircraftCockpit); - connect(m_voiceClient.data(), &CAfvClient::ptt, this, &IContextAudio::ptt); + connect(m_voiceClient, &CAfvClient::outputVolumePeakVU, this, &IContextAudio::outputVolumePeakVU); + connect(m_voiceClient, &CAfvClient::inputVolumePeakVU, this, &IContextAudio::inputVolumePeakVU); + connect(m_voiceClient, &CAfvClient::receivingCallsignsChanged, this, &IContextAudio::receivingCallsignsChanged); + connect(m_voiceClient, &CAfvClient::updatedFromOwnAircraftCockpit, this, &IContextAudio::updatedFromOwnAircraftCockpit); + connect(m_voiceClient, &CAfvClient::ptt, this, &IContextAudio::ptt); const CSettings as = m_audioSettings.getThreadLocal(); this->setVoiceOutputVolume(as.getOutVolume()); @@ -107,7 +107,8 @@ namespace BlackCore { m_voiceClient->stopAudio(); m_voiceClient->quitAndWait(); - Q_ASSERT_X(CThreadUtils::isCurrentThreadObjectThread(m_voiceClient.data()), Q_FUNC_INFO, "Needs to be back in current thread"); + Q_ASSERT_X(CThreadUtils::isCurrentThreadObjectThread(m_voiceClient), Q_FUNC_INFO, "Needs to be back in current thread"); + m_voiceClient = nullptr; } QObject::disconnect(this); } diff --git a/src/blackcore/context/contextaudio.h b/src/blackcore/context/contextaudio.h index ab4f2e063..424700c4d 100644 --- a/src/blackcore/context/contextaudio.h +++ b/src/blackcore/context/contextaudio.h @@ -260,7 +260,7 @@ namespace BlackCore BlackMisc::CSetting m_outputDeviceSetting { this, &IContextAudio::changeDeviceSettings }; // AFV - QScopedPointer m_voiceClient; + Afv::Clients::CAfvClient *m_voiceClient = nullptr; // Players BlackSound::CSelcalPlayer *m_selcalPlayer = nullptr;