mirror of
https://github.com/f4exb/sdrangel.git
synced 2026-06-18 05:38:47 -04:00
MainWindow: Add FSMs to avoid blocking on the GUI thread.
DSPDevice*Engine: Add signals to indicate when commands have been processed. DSPDeviceSourceEngine: Fix small memory leak. DSPEngine::removeDeviceEngineAt: Remove wait to avoid blocking thread. Return QThread to get finished signal. DSPEngine::addDevice*Engine: Don't call deleteLater for device*Engine, as these objects are deleted manually in MainWindow, which will crash if deleteLater called first.
This commit is contained in:
@@ -70,12 +70,6 @@ DSPDeviceSourceEngine *DSPEngine::addDeviceSourceEngine()
|
||||
m_deviceEngineReferences.push_back(DeviceEngineReference{0, m_deviceSourceEngines.back(), nullptr, nullptr, deviceThread});
|
||||
deviceSourceEngine->moveToThread(deviceThread);
|
||||
|
||||
QObject::connect(
|
||||
deviceThread,
|
||||
&QThread::finished,
|
||||
deviceSourceEngine,
|
||||
&QObject::deleteLater
|
||||
);
|
||||
QObject::connect(
|
||||
deviceThread,
|
||||
&QThread::finished,
|
||||
@@ -118,12 +112,6 @@ DSPDeviceSinkEngine *DSPEngine::addDeviceSinkEngine()
|
||||
m_deviceEngineReferences.push_back(DeviceEngineReference{1, nullptr, m_deviceSinkEngines.back(), nullptr, deviceThread});
|
||||
deviceSinkEngine->moveToThread(deviceThread);
|
||||
|
||||
QObject::connect(
|
||||
deviceThread,
|
||||
&QThread::finished,
|
||||
deviceSinkEngine,
|
||||
&QObject::deleteLater
|
||||
);
|
||||
QObject::connect(
|
||||
deviceThread,
|
||||
&QThread::finished,
|
||||
@@ -166,12 +154,6 @@ DSPDeviceMIMOEngine *DSPEngine::addDeviceMIMOEngine()
|
||||
m_deviceEngineReferences.push_back(DeviceEngineReference{2, nullptr, nullptr, m_deviceMIMOEngines.back(), deviceThread});
|
||||
deviceMIMOEngine->moveToThread(deviceThread);
|
||||
|
||||
QObject::connect(
|
||||
deviceThread,
|
||||
&QThread::finished,
|
||||
deviceMIMOEngine,
|
||||
&QObject::deleteLater
|
||||
);
|
||||
QObject::connect(
|
||||
deviceThread,
|
||||
&QThread::finished,
|
||||
@@ -205,38 +187,39 @@ void DSPEngine::removeLastDeviceMIMOEngine()
|
||||
}
|
||||
}
|
||||
|
||||
void DSPEngine::removeDeviceEngineAt(int deviceIndex)
|
||||
QThread * DSPEngine::removeDeviceEngineAt(int deviceIndex)
|
||||
{
|
||||
if (deviceIndex >= m_deviceEngineReferences.size()) {
|
||||
return;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
QThread *deviceThread = nullptr;
|
||||
|
||||
if (m_deviceEngineReferences[deviceIndex].m_deviceEngineType == 0) // source
|
||||
{
|
||||
DSPDeviceSourceEngine *deviceEngine = m_deviceEngineReferences[deviceIndex].m_deviceSourceEngine;
|
||||
QThread *deviceThread = m_deviceEngineReferences[deviceIndex].m_thread;
|
||||
deviceThread = m_deviceEngineReferences[deviceIndex].m_thread;
|
||||
deviceThread->exit();
|
||||
deviceThread->wait();
|
||||
m_deviceSourceEngines.removeAll(deviceEngine);
|
||||
}
|
||||
else if (m_deviceEngineReferences[deviceIndex].m_deviceEngineType == 1) // sink
|
||||
{
|
||||
DSPDeviceSinkEngine *deviceEngine = m_deviceEngineReferences[deviceIndex].m_deviceSinkEngine;
|
||||
QThread *deviceThread = m_deviceEngineReferences[deviceIndex].m_thread;
|
||||
deviceThread = m_deviceEngineReferences[deviceIndex].m_thread;
|
||||
deviceThread->exit();
|
||||
deviceThread->wait();
|
||||
m_deviceSinkEngines.removeAll(deviceEngine);
|
||||
}
|
||||
else if (m_deviceEngineReferences[deviceIndex].m_deviceEngineType == 2) // MIMO
|
||||
{
|
||||
DSPDeviceMIMOEngine *deviceEngine = m_deviceEngineReferences[deviceIndex].m_deviceMIMOEngine;
|
||||
QThread *deviceThread = m_deviceEngineReferences[deviceIndex].m_thread;
|
||||
deviceThread = m_deviceEngineReferences[deviceIndex].m_thread;
|
||||
deviceThread->exit();
|
||||
deviceThread->wait();
|
||||
m_deviceMIMOEngines.removeAll(deviceEngine);
|
||||
}
|
||||
|
||||
m_deviceEngineReferences.removeAt(deviceIndex);
|
||||
|
||||
return deviceThread;
|
||||
}
|
||||
|
||||
void DSPEngine::createFFTFactory(const QString& fftWisdomFileName)
|
||||
|
||||
Reference in New Issue
Block a user