Test Source: fixed worker lifecycle. Fixes issue #626

This commit is contained in:
f4exb 2020-09-11 00:27:53 +02:00
parent 1e0be6a6f7
commit f9f70d91e3
1 changed files with 6 additions and 10 deletions

View File

@ -50,6 +50,9 @@ TestSourceInput::TestSourceInput(DeviceAPI *deviceAPI) :
qCritical("TestSourceInput::TestSourceInput: Could not allocate SampleFifo");
}
m_testSourceWorker = new TestSourceWorker(&m_sampleFifo);
m_testSourceWorker->moveToThread(&m_testSourceWorkerThread);
m_networkManager = new QNetworkAccessManager();
connect(m_networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(networkManagerFinished(QNetworkReply*)));
}
@ -62,6 +65,8 @@ TestSourceInput::~TestSourceInput()
if (m_running) {
stop();
}
m_testSourceWorker->deleteLater();
}
void TestSourceInput::destroy()
@ -82,8 +87,6 @@ bool TestSourceInput::start()
stop();
}
m_testSourceWorker = new TestSourceWorker(&m_sampleFifo);
m_testSourceWorker->moveToThread(&m_testSourceWorkerThread);
m_testSourceWorker->setSamplerate(m_settings.m_sampleRate);
startWorker();
@ -98,14 +101,7 @@ bool TestSourceInput::start()
void TestSourceInput::stop()
{
QMutexLocker mutexLocker(&m_mutex);
if (m_testSourceWorker)
{
stopWorker();
m_testSourceWorker->deleteLater();
m_testSourceWorker = nullptr;
}
stopWorker();
m_running = false;
}