mirror of
https://github.com/f4exb/sdrangel.git
synced 2026-06-04 23:14:47 -04:00
Main Window: fixed memory leak with remove last device
This commit is contained in:
@@ -797,6 +797,7 @@ int WebAPIAdapterSrv::devicesetFocusPatch(
|
||||
|
||||
int WebAPIAdapterSrv::devicesetDevicePut(
|
||||
int deviceSetIndex,
|
||||
SWGSDRangel::SWGDeviceListItem& query,
|
||||
SWGSDRangel::SWGDeviceListItem& response,
|
||||
SWGSDRangel::SWGErrorResponse& error)
|
||||
{
|
||||
@@ -804,46 +805,48 @@ int WebAPIAdapterSrv::devicesetDevicePut(
|
||||
{
|
||||
DeviceSet *deviceSet = m_mainCore.m_deviceSets[deviceSetIndex];
|
||||
|
||||
if ((response.getTx() == 0) && (deviceSet->m_deviceSinkEngine))
|
||||
if ((query.getTx() == 0) && (deviceSet->m_deviceSinkEngine))
|
||||
{
|
||||
error.init();
|
||||
*error.getMessage() = QString("Device type (Rx) and device set type (Tx) mismatch");
|
||||
return 404;
|
||||
}
|
||||
|
||||
if ((response.getTx() != 0) && (deviceSet->m_deviceSourceEngine))
|
||||
if ((query.getTx() != 0) && (deviceSet->m_deviceSourceEngine))
|
||||
{
|
||||
error.init();
|
||||
*error.getMessage() = QString("Device type (Tx) and device set type (Rx) mismatch");
|
||||
return 404;
|
||||
}
|
||||
|
||||
int nbSamplingDevices = response.getTx() != 0 ? DeviceEnumerator::instance()->getNbTxSamplingDevices() : DeviceEnumerator::instance()->getNbRxSamplingDevices();
|
||||
int tx = response.getTx();
|
||||
int nbSamplingDevices = query.getTx() != 0 ? DeviceEnumerator::instance()->getNbTxSamplingDevices() : DeviceEnumerator::instance()->getNbRxSamplingDevices();
|
||||
int tx = query.getTx();
|
||||
|
||||
for (int i = 0; i < nbSamplingDevices; i++)
|
||||
{
|
||||
PluginInterface::SamplingDevice samplingDevice = response.getTx() ? DeviceEnumerator::instance()->getTxSamplingDevice(i) : DeviceEnumerator::instance()->getRxSamplingDevice(i);
|
||||
PluginInterface::SamplingDevice samplingDevice = query.getTx() ? DeviceEnumerator::instance()->getTxSamplingDevice(i) : DeviceEnumerator::instance()->getRxSamplingDevice(i);
|
||||
|
||||
if (response.getDisplayedName() && (*response.getDisplayedName() != samplingDevice.displayedName)) {
|
||||
if (query.getDisplayedName() && (*query.getDisplayedName() != samplingDevice.displayedName)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (response.getHwType() && (*response.getHwType() != samplingDevice.hardwareId)) {
|
||||
if (query.getHwType() && (*query.getHwType() != samplingDevice.hardwareId)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((response.getSequence() >= 0) && (response.getSequence() != samplingDevice.sequence)) {
|
||||
if ((query.getSequence() >= 0) && (query.getSequence() != samplingDevice.sequence)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (response.getSerial() && (*response.getSerial() != samplingDevice.serial)) {
|
||||
if (query.getSerial() && (*query.getSerial() != samplingDevice.serial)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((response.getStreamIndex() >= 0) && (response.getStreamIndex() != samplingDevice.deviceItemIndex)) {
|
||||
if ((query.getStreamIndex() >= 0) && (query.getStreamIndex() != samplingDevice.deviceItemIndex)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
MainCore::MsgSetDevice *msg = MainCore::MsgSetDevice::create(deviceSetIndex, i, response.getTx() != 0);
|
||||
MainCore::MsgSetDevice *msg = MainCore::MsgSetDevice::create(deviceSetIndex, i, query.getTx() != 0);
|
||||
m_mainCore.m_inputMessageQueue.push(msg);
|
||||
|
||||
response.init();
|
||||
@@ -860,6 +863,7 @@ int WebAPIAdapterSrv::devicesetDevicePut(
|
||||
return 202;
|
||||
}
|
||||
|
||||
error.init();
|
||||
*error.getMessage() = QString("Device not found");
|
||||
return 404;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user