mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-12-23 10:05:46 -05:00
Main Window: fixed memory leak with remove last device
This commit is contained in:
parent
cbcb7b6370
commit
8f3ef9e76d
@ -370,6 +370,7 @@ public:
|
||||
*/
|
||||
virtual int devicesetDevicePut(
|
||||
int deviceSetIndex __attribute__((unused)),
|
||||
SWGSDRangel::SWGDeviceListItem& query __attribute__((unused)),
|
||||
SWGSDRangel::SWGDeviceListItem& response __attribute__((unused)),
|
||||
SWGSDRangel::SWGErrorResponse& error)
|
||||
{
|
||||
|
@ -868,11 +868,12 @@ void WebAPIRequestMapper::devicesetDeviceService(const std::string& indexStr, qt
|
||||
|
||||
if (parseJsonBody(jsonStr, jsonObject, response))
|
||||
{
|
||||
SWGSDRangel::SWGDeviceListItem query;
|
||||
SWGSDRangel::SWGDeviceListItem normalResponse;
|
||||
|
||||
if (validateDeviceListItem(normalResponse, jsonObject))
|
||||
if (validateDeviceListItem(query, jsonObject))
|
||||
{
|
||||
int status = m_adapter->devicesetDevicePut(deviceSetIndex, normalResponse, errorResponse);
|
||||
int status = m_adapter->devicesetDevicePut(deviceSetIndex, query, normalResponse, errorResponse);
|
||||
response.setStatus(status);
|
||||
|
||||
if (status/100 == 2) {
|
||||
|
@ -395,6 +395,7 @@ void MainWindow::removeLastDevice()
|
||||
ui->tabInputsView->setTabToolTip(i, m_deviceWidgetTabs[i].displayName);
|
||||
}
|
||||
|
||||
delete m_deviceUIs.back()->m_deviceSourceAPI;
|
||||
delete m_deviceUIs.back();
|
||||
|
||||
lastDeviceEngine->stop();
|
||||
@ -434,6 +435,7 @@ void MainWindow::removeLastDevice()
|
||||
ui->tabInputsView->setTabToolTip(i, m_deviceWidgetTabs[i].displayName);
|
||||
}
|
||||
|
||||
delete m_deviceUIs.back()->m_deviceSinkAPI;
|
||||
delete m_deviceUIs.back();
|
||||
|
||||
lastDeviceEngine->stop();
|
||||
|
@ -696,6 +696,7 @@ int WebAPIAdapterGUI::devicesetFocusPatch(
|
||||
|
||||
int WebAPIAdapterGUI::devicesetDevicePut(
|
||||
int deviceSetIndex,
|
||||
SWGSDRangel::SWGDeviceListItem& query,
|
||||
SWGSDRangel::SWGDeviceListItem& response,
|
||||
SWGSDRangel::SWGErrorResponse& error)
|
||||
{
|
||||
@ -703,46 +704,48 @@ int WebAPIAdapterGUI::devicesetDevicePut(
|
||||
{
|
||||
DeviceUISet *deviceSet = m_mainWindow.m_deviceUIs[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;
|
||||
}
|
||||
|
||||
MainWindow::MsgSetDevice *msg = MainWindow::MsgSetDevice::create(deviceSetIndex, i, response.getTx() != 0);
|
||||
MainWindow::MsgSetDevice *msg = MainWindow::MsgSetDevice::create(deviceSetIndex, i, query.getTx() != 0);
|
||||
m_mainWindow.m_inputMessageQueue.push(msg);
|
||||
|
||||
response.init();
|
||||
@ -759,6 +762,7 @@ int WebAPIAdapterGUI::devicesetDevicePut(
|
||||
return 202;
|
||||
}
|
||||
|
||||
error.init();
|
||||
*error.getMessage() = QString("Device not found");
|
||||
return 404;
|
||||
}
|
||||
@ -766,7 +770,6 @@ int WebAPIAdapterGUI::devicesetDevicePut(
|
||||
{
|
||||
error.init();
|
||||
*error.getMessage() = QString("There is no device set with index %1").arg(deviceSetIndex);
|
||||
|
||||
return 404;
|
||||
}
|
||||
}
|
||||
|
@ -127,6 +127,7 @@ public:
|
||||
|
||||
virtual int devicesetDevicePut(
|
||||
int deviceSetIndex,
|
||||
SWGSDRangel::SWGDeviceListItem& query,
|
||||
SWGSDRangel::SWGDeviceListItem& response,
|
||||
SWGSDRangel::SWGErrorResponse& error);
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -138,6 +138,7 @@ public:
|
||||
|
||||
virtual int devicesetDevicePut(
|
||||
int deviceSetIndex,
|
||||
SWGSDRangel::SWGDeviceListItem& query,
|
||||
SWGSDRangel::SWGDeviceListItem& response,
|
||||
SWGSDRangel::SWGErrorResponse& error);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user