1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-26 09:48:45 -05:00

Massive UI revamping (v7): Fixed random deletion of device sets. Fixes #1211

This commit is contained in:
f4exb 2022-04-25 01:18:07 +02:00
parent 5f9d14a56e
commit 3259cf7f0a
2 changed files with 19 additions and 20 deletions

View File

@ -63,7 +63,7 @@ DSPDeviceSourceEngine *DSPEngine::addDeviceSourceEngine()
{ {
m_deviceSourceEngines.push_back(new DSPDeviceSourceEngine(m_deviceSourceEnginesUIDSequence)); m_deviceSourceEngines.push_back(new DSPDeviceSourceEngine(m_deviceSourceEnginesUIDSequence));
m_deviceSourceEnginesUIDSequence++; m_deviceSourceEnginesUIDSequence++;
m_deviceEngineReferences.push_back(DeviceEngineReference{0, m_deviceSourceEngines.size() - 1}); m_deviceEngineReferences.push_back(DeviceEngineReference{0, m_deviceSourceEngines.back(), nullptr, nullptr});
return m_deviceSourceEngines.back(); return m_deviceSourceEngines.back();
} }
@ -72,13 +72,12 @@ void DSPEngine::removeLastDeviceSourceEngine()
if (m_deviceSourceEngines.size() > 0) if (m_deviceSourceEngines.size() > 0)
{ {
DSPDeviceSourceEngine *lastDeviceEngine = m_deviceSourceEngines.back(); DSPDeviceSourceEngine *lastDeviceEngine = m_deviceSourceEngines.back();
int lastSourceDeviceEngineIndex = m_deviceSourceEngines.size() - 1;
delete lastDeviceEngine; delete lastDeviceEngine;
m_deviceSourceEngines.pop_back(); m_deviceSourceEngines.pop_back();
for (int i = 0; i < m_deviceEngineReferences.size(); i++) for (int i = 0; i < m_deviceEngineReferences.size(); i++)
{ {
if (m_deviceEngineReferences[i].deviceEngineIndex == lastSourceDeviceEngineIndex) if (m_deviceEngineReferences[i].m_deviceSourceEngine == lastDeviceEngine)
{ {
m_deviceEngineReferences.removeAt(i); m_deviceEngineReferences.removeAt(i);
break; break;
@ -91,7 +90,7 @@ DSPDeviceSinkEngine *DSPEngine::addDeviceSinkEngine()
{ {
m_deviceSinkEngines.push_back(new DSPDeviceSinkEngine(m_deviceSinkEnginesUIDSequence)); m_deviceSinkEngines.push_back(new DSPDeviceSinkEngine(m_deviceSinkEnginesUIDSequence));
m_deviceSinkEnginesUIDSequence++; m_deviceSinkEnginesUIDSequence++;
m_deviceEngineReferences.push_back(DeviceEngineReference{1, m_deviceSinkEngines.size() - 1}); m_deviceEngineReferences.push_back(DeviceEngineReference{1, nullptr, m_deviceSinkEngines.back(), nullptr});
return m_deviceSinkEngines.back(); return m_deviceSinkEngines.back();
} }
@ -100,13 +99,12 @@ void DSPEngine::removeLastDeviceSinkEngine()
if (m_deviceSinkEngines.size() > 0) if (m_deviceSinkEngines.size() > 0)
{ {
DSPDeviceSinkEngine *lastDeviceEngine = m_deviceSinkEngines.back(); DSPDeviceSinkEngine *lastDeviceEngine = m_deviceSinkEngines.back();
int lastSinkDeviceEngineIndex = m_deviceSinkEngines.size() - 1;
delete lastDeviceEngine; delete lastDeviceEngine;
m_deviceSinkEngines.pop_back(); m_deviceSinkEngines.pop_back();
for (int i = 0; i < m_deviceEngineReferences.size(); i++) for (int i = 0; i < m_deviceEngineReferences.size(); i++)
{ {
if (m_deviceEngineReferences[i].deviceEngineIndex == lastSinkDeviceEngineIndex) if (m_deviceEngineReferences[i].m_deviceSinkEngine == lastDeviceEngine)
{ {
m_deviceEngineReferences.removeAt(i); m_deviceEngineReferences.removeAt(i);
break; break;
@ -119,7 +117,7 @@ DSPDeviceMIMOEngine *DSPEngine::addDeviceMIMOEngine()
{ {
m_deviceMIMOEngines.push_back(new DSPDeviceMIMOEngine(m_deviceMIMOEnginesUIDSequence)); m_deviceMIMOEngines.push_back(new DSPDeviceMIMOEngine(m_deviceMIMOEnginesUIDSequence));
m_deviceMIMOEnginesUIDSequence++; m_deviceMIMOEnginesUIDSequence++;
m_deviceEngineReferences.push_back(DeviceEngineReference{2, m_deviceMIMOEngines.size() - 1}); m_deviceEngineReferences.push_back(DeviceEngineReference{2, nullptr, nullptr, m_deviceMIMOEngines.back()});
return m_deviceMIMOEngines.back(); return m_deviceMIMOEngines.back();
} }
@ -128,13 +126,12 @@ void DSPEngine::removeLastDeviceMIMOEngine()
if (m_deviceMIMOEngines.size() > 0) if (m_deviceMIMOEngines.size() > 0)
{ {
DSPDeviceMIMOEngine *lastDeviceEngine = m_deviceMIMOEngines.back(); DSPDeviceMIMOEngine *lastDeviceEngine = m_deviceMIMOEngines.back();
int lastMIMODeviceEngineIndex = m_deviceMIMOEngines.size() - 1;
delete lastDeviceEngine; delete lastDeviceEngine;
m_deviceMIMOEngines.pop_back(); m_deviceMIMOEngines.pop_back();
for (int i = 0; i < m_deviceEngineReferences.size(); i++) for (int i = 0; i < m_deviceEngineReferences.size(); i++)
{ {
if (m_deviceEngineReferences[i].deviceEngineIndex == lastMIMODeviceEngineIndex) if (m_deviceEngineReferences[i].m_deviceMIMOEngine == lastDeviceEngine)
{ {
m_deviceEngineReferences.removeAt(i); m_deviceEngineReferences.removeAt(i);
break; break;
@ -149,23 +146,23 @@ void DSPEngine::removeDeviceEngineAt(int deviceIndex)
return; return;
} }
if (m_deviceEngineReferences[deviceIndex].deviceEngineTYpe == 0) // source if (m_deviceEngineReferences[deviceIndex].m_deviceEngineType == 0) // source
{ {
DSPDeviceSourceEngine *deviceEngine = m_deviceSourceEngines[m_deviceEngineReferences[deviceIndex].deviceEngineIndex]; DSPDeviceSourceEngine *deviceEngine = m_deviceEngineReferences[deviceIndex].m_deviceSourceEngine;
delete deviceEngine; delete deviceEngine;
m_deviceSourceEngines.removeAt(m_deviceEngineReferences[deviceIndex].deviceEngineIndex); m_deviceSourceEngines.removeAll(deviceEngine);
} }
else if (m_deviceEngineReferences[deviceIndex].deviceEngineTYpe == 1) // sink else if (m_deviceEngineReferences[deviceIndex].m_deviceEngineType == 1) // sink
{ {
DSPDeviceSinkEngine *deviceEngine = m_deviceSinkEngines[m_deviceEngineReferences[deviceIndex].deviceEngineIndex]; DSPDeviceSinkEngine *deviceEngine = m_deviceEngineReferences[deviceIndex].m_deviceSinkEngine;
delete deviceEngine; delete deviceEngine;
m_deviceSinkEngines.removeAt(m_deviceEngineReferences[deviceIndex].deviceEngineIndex); m_deviceSinkEngines.removeAll(deviceEngine);
} }
else if (m_deviceEngineReferences[deviceIndex].deviceEngineTYpe == 2) // MIMO else if (m_deviceEngineReferences[deviceIndex].m_deviceEngineType == 2) // MIMO
{ {
DSPDeviceMIMOEngine *deviceEngine = m_deviceMIMOEngines[m_deviceEngineReferences[deviceIndex].deviceEngineIndex]; DSPDeviceMIMOEngine *deviceEngine = m_deviceEngineReferences[deviceIndex].m_deviceMIMOEngine;
delete deviceEngine; delete deviceEngine;
m_deviceMIMOEngines.removeAt(m_deviceEngineReferences[deviceIndex].deviceEngineIndex); m_deviceMIMOEngines.removeAll(deviceEngine);
} }
m_deviceEngineReferences.removeAt(deviceIndex); m_deviceEngineReferences.removeAt(deviceIndex);

View File

@ -90,8 +90,10 @@ public:
private: private:
struct DeviceEngineReference struct DeviceEngineReference
{ {
int deviceEngineTYpe; //!< 0: Rx, 1: Tx, 2: MIMO int m_deviceEngineType; //!< 0: Rx, 1: Tx, 2: MIMO
int deviceEngineIndex; DSPDeviceSourceEngine *m_deviceSourceEngine;
DSPDeviceSinkEngine *m_deviceSinkEngine;
DSPDeviceMIMOEngine *m_deviceMIMOEngine;
}; };
QList<DSPDeviceSourceEngine*> m_deviceSourceEngines; QList<DSPDeviceSourceEngine*> m_deviceSourceEngines;