From d507f496267b335c06b9f39af3ed00be788cb73e Mon Sep 17 00:00:00 2001 From: Jon Beniston Date: Fri, 15 Jan 2021 11:24:21 +0000 Subject: [PATCH] Instantiate QNetworkAccessManager to avoid crash on reverse API usage --- plugins/feature/afc/afc.cpp | 4 ++++ plugins/feature/aprs/aprs.cpp | 4 ++++ plugins/feature/demodanalyzer/demodanalyzer.cpp | 4 ++++ plugins/feature/gs232controller/gs232controller.cpp | 4 ++++ plugins/feature/map/map.cpp | 4 ++++ plugins/feature/rigctlserver/rigctlserver.cpp | 4 ++++ plugins/feature/simpleptt/simpleptt.cpp | 4 ++++ plugins/feature/startracker/startracker.cpp | 4 ++++ plugins/feature/vorlocalizer/vorlocalizer.cpp | 4 ++++ 9 files changed, 36 insertions(+) diff --git a/plugins/feature/afc/afc.cpp b/plugins/feature/afc/afc.cpp index 1e0c1732a..b2893d2b3 100644 --- a/plugins/feature/afc/afc.cpp +++ b/plugins/feature/afc/afc.cpp @@ -54,10 +54,14 @@ AFC::AFC(WebAPIAdapterInterface *webAPIAdapterInterface) : m_worker = new AFCWorker(webAPIAdapterInterface); m_state = StIdle; m_errorMessage = "AFC error"; + m_networkManager = new QNetworkAccessManager(); + connect(m_networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(networkManagerFinished(QNetworkReply*))); } AFC::~AFC() { + disconnect(m_networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(networkManagerFinished(QNetworkReply*))); + delete m_networkManager; if (m_worker->isRunning()) { stop(); } diff --git a/plugins/feature/aprs/aprs.cpp b/plugins/feature/aprs/aprs.cpp index 51e072f93..a03a32b83 100644 --- a/plugins/feature/aprs/aprs.cpp +++ b/plugins/feature/aprs/aprs.cpp @@ -50,10 +50,14 @@ APRS::APRS(WebAPIAdapterInterface *webAPIAdapterInterface) : m_errorMessage = "APRS error"; connect(&m_updatePipesTimer, SIGNAL(timeout()), this, SLOT(updatePipes())); m_updatePipesTimer.start(1000); + m_networkManager = new QNetworkAccessManager(); + connect(m_networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(networkManagerFinished(QNetworkReply*))); } APRS::~APRS() { + disconnect(m_networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(networkManagerFinished(QNetworkReply*))); + delete m_networkManager; if (m_worker->isRunning()) { stop(); } diff --git a/plugins/feature/demodanalyzer/demodanalyzer.cpp b/plugins/feature/demodanalyzer/demodanalyzer.cpp index 4ece5f8d5..35d45d47b 100644 --- a/plugins/feature/demodanalyzer/demodanalyzer.cpp +++ b/plugins/feature/demodanalyzer/demodanalyzer.cpp @@ -56,10 +56,14 @@ DemodAnalyzer::DemodAnalyzer(WebAPIAdapterInterface *webAPIAdapterInterface) : m_worker = new DemodAnalyzerWorker(); m_state = StIdle; m_errorMessage = "DemodAnalyzer error"; + m_networkManager = new QNetworkAccessManager(); + connect(m_networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(networkManagerFinished(QNetworkReply*))); } DemodAnalyzer::~DemodAnalyzer() { + disconnect(m_networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(networkManagerFinished(QNetworkReply*))); + delete m_networkManager; if (m_worker->isRunning()) { stop(); } diff --git a/plugins/feature/gs232controller/gs232controller.cpp b/plugins/feature/gs232controller/gs232controller.cpp index 57e182e81..0ea28d684 100644 --- a/plugins/feature/gs232controller/gs232controller.cpp +++ b/plugins/feature/gs232controller/gs232controller.cpp @@ -56,10 +56,14 @@ GS232Controller::GS232Controller(WebAPIAdapterInterface *webAPIAdapterInterface) m_selectedPipe = nullptr; connect(&m_updatePipesTimer, SIGNAL(timeout()), this, SLOT(updatePipes())); m_updatePipesTimer.start(1000); + m_networkManager = new QNetworkAccessManager(); + connect(m_networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(networkManagerFinished(QNetworkReply*))); } GS232Controller::~GS232Controller() { + disconnect(m_networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(networkManagerFinished(QNetworkReply*))); + delete m_networkManager; if (m_worker->isRunning()) { stop(); } diff --git a/plugins/feature/map/map.cpp b/plugins/feature/map/map.cpp index 91558ccad..0562e00d4 100644 --- a/plugins/feature/map/map.cpp +++ b/plugins/feature/map/map.cpp @@ -49,10 +49,14 @@ Map::Map(WebAPIAdapterInterface *webAPIAdapterInterface) : m_errorMessage = "Map error"; connect(&m_updatePipesTimer, SIGNAL(timeout()), this, SLOT(updatePipes())); m_updatePipesTimer.start(1000); + m_networkManager = new QNetworkAccessManager(); + connect(m_networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(networkManagerFinished(QNetworkReply*))); } Map::~Map() { + disconnect(m_networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(networkManagerFinished(QNetworkReply*))); + delete m_networkManager; } bool Map::handleMessage(const Message& cmd) diff --git a/plugins/feature/rigctlserver/rigctlserver.cpp b/plugins/feature/rigctlserver/rigctlserver.cpp index b9cae35e5..7e7a51744 100644 --- a/plugins/feature/rigctlserver/rigctlserver.cpp +++ b/plugins/feature/rigctlserver/rigctlserver.cpp @@ -45,10 +45,14 @@ RigCtlServer::RigCtlServer(WebAPIAdapterInterface *webAPIAdapterInterface) : m_worker = new RigCtlServerWorker(webAPIAdapterInterface); m_state = StIdle; m_errorMessage = "RigCtlServer error"; + m_networkManager = new QNetworkAccessManager(); + connect(m_networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(networkManagerFinished(QNetworkReply*))); } RigCtlServer::~RigCtlServer() { + disconnect(m_networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(networkManagerFinished(QNetworkReply*))); + delete m_networkManager; if (m_worker->isRunning()) { stop(); } diff --git a/plugins/feature/simpleptt/simpleptt.cpp b/plugins/feature/simpleptt/simpleptt.cpp index 31a9ea0d7..d7db24a2e 100644 --- a/plugins/feature/simpleptt/simpleptt.cpp +++ b/plugins/feature/simpleptt/simpleptt.cpp @@ -46,10 +46,14 @@ SimplePTT::SimplePTT(WebAPIAdapterInterface *webAPIAdapterInterface) : m_worker = new SimplePTTWorker(webAPIAdapterInterface); m_state = StIdle; m_errorMessage = "SimplePTT error"; + m_networkManager = new QNetworkAccessManager(); + connect(m_networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(networkManagerFinished(QNetworkReply*))); } SimplePTT::~SimplePTT() { + disconnect(m_networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(networkManagerFinished(QNetworkReply*))); + delete m_networkManager; if (m_worker->isRunning()) { stop(); } diff --git a/plugins/feature/startracker/startracker.cpp b/plugins/feature/startracker/startracker.cpp index 816b81a30..7714f74ec 100644 --- a/plugins/feature/startracker/startracker.cpp +++ b/plugins/feature/startracker/startracker.cpp @@ -45,10 +45,14 @@ StarTracker::StarTracker(WebAPIAdapterInterface *webAPIAdapterInterface) : m_worker = new StarTrackerWorker(this, webAPIAdapterInterface); m_state = StIdle; m_errorMessage = "StarTracker error"; + m_networkManager = new QNetworkAccessManager(); + connect(m_networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(networkManagerFinished(QNetworkReply*))); } StarTracker::~StarTracker() { + disconnect(m_networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(networkManagerFinished(QNetworkReply*))); + delete m_networkManager; if (m_worker->isRunning()) { stop(); } diff --git a/plugins/feature/vorlocalizer/vorlocalizer.cpp b/plugins/feature/vorlocalizer/vorlocalizer.cpp index 23ddf6c7f..6aec80ae6 100644 --- a/plugins/feature/vorlocalizer/vorlocalizer.cpp +++ b/plugins/feature/vorlocalizer/vorlocalizer.cpp @@ -53,10 +53,14 @@ VORLocalizer::VORLocalizer(WebAPIAdapterInterface *webAPIAdapterInterface) : m_worker = new VorLocalizerWorker(webAPIAdapterInterface); m_state = StIdle; m_errorMessage = "VORLocalizer error"; + m_networkManager = new QNetworkAccessManager(); + connect(m_networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(networkManagerFinished(QNetworkReply*))); } VORLocalizer::~VORLocalizer() { + disconnect(m_networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(networkManagerFinished(QNetworkReply*))); + delete m_networkManager; if (m_worker->isRunning()) { stop(); }