1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2026-06-02 06:04:39 -04:00

Revert "Web API: removed call to init() on generated Swagger objects as this is now handled automatically at construction time. Suppresses memory leaks."

This reverts commit aa796c30b6.
This commit is contained in:
f4exb
2018-02-13 20:12:54 +01:00
parent 5203d9b0c1
commit c23828a1fa
2 changed files with 105 additions and 0 deletions
+52
View File
@@ -85,6 +85,7 @@ int WebAPIAdapterGUI::instanceSummary(
#endif
SWGSDRangel::SWGLoggingInfo *logging = response.getLogging();
logging->init();
logging->setDumpToFile(m_mainWindow.m_logger->getUseFileLogger() ? 1 : 0);
if (logging->getDumpToFile()) {
@@ -204,6 +205,7 @@ int WebAPIAdapterGUI::instanceLoggingPut(
m_mainWindow.setLoggingOptions();
// build response
response.init();
getMsgTypeString(m_mainWindow.m_settings.getConsoleMinLogLevel(), *response.getConsoleLevel());
response.setDumpToFile(m_mainWindow.m_settings.getUseLogFile() ? 1 : 0);
getMsgTypeString(m_mainWindow.m_settings.getFileMinLogLevel(), *response.getFileLevel());
@@ -221,6 +223,7 @@ int WebAPIAdapterGUI::instanceAudioGet(
int nbInputDevices = audioInputDevices.size();
int nbOutputDevices = audioOutputDevices.size();
response.init();
response.setNbInputDevices(nbInputDevices);
response.setInputDeviceSelectedIndex(m_mainWindow.m_audioDeviceInfo.getInputDeviceIndex());
response.setNbOutputDevices(nbOutputDevices);
@@ -313,6 +316,7 @@ int WebAPIAdapterGUI::instanceDVSerialPatch(
{
m_mainWindow.m_dspEngine->setDVSerialSupport(dvserial);
m_mainWindow.ui->action_DV_Serial->setChecked(dvserial);
response.init();
if (dvserial)
{
@@ -347,6 +351,7 @@ int WebAPIAdapterGUI::instancePresetsGet(
int nbGroups = 0;
int nbPresetsThisGroup = 0;
QString groupName;
response.init();
QList<SWGSDRangel::SWGPresetGroup*> *groups = response.getGroups();
QList<SWGSDRangel::SWGPresetItem*> *swgPresets = 0;
int i = 0;
@@ -361,6 +366,7 @@ int WebAPIAdapterGUI::instancePresetsGet(
{
if (i > 0) { groups->back()->setNbPresets(nbPresetsThisGroup); }
groups->append(new SWGSDRangel::SWGPresetGroup);
groups->back()->init();
groupName = preset->getGroup();
*groups->back()->getGroupName() = groupName;
swgPresets = groups->back()->getPresets();
@@ -426,6 +432,7 @@ int WebAPIAdapterGUI::instancePresetPatch(
MainWindow::MsgLoadPreset *msg = MainWindow::MsgLoadPreset::create(selectedPreset, deviceSetIndex);
m_mainWindow.m_inputMessageQueue.push(msg);
response.init();
response.setCenterFrequency(selectedPreset->getCenterFrequency());
*response.getGroupName() = selectedPreset->getGroup();
*response.getType() = selectedPreset->isSourcePreset() ? "R" : "T";
@@ -481,6 +488,7 @@ int WebAPIAdapterGUI::instancePresetPut(
MainWindow::MsgSavePreset *msg = MainWindow::MsgSavePreset::create(const_cast<Preset*>(selectedPreset), deviceSetIndex, false);
m_mainWindow.m_inputMessageQueue.push(msg);
response.init();
response.setCenterFrequency(selectedPreset->getCenterFrequency());
*response.getGroupName() = selectedPreset->getGroup();
*response.getType() = selectedPreset->isSourcePreset() ? "R" : "T";
@@ -524,6 +532,7 @@ int WebAPIAdapterGUI::instancePresetPost(
MainWindow::MsgSavePreset *msg = MainWindow::MsgSavePreset::create(const_cast<Preset*>(selectedPreset), deviceSetIndex, true);
m_mainWindow.m_inputMessageQueue.push(msg);
response.init();
response.setCenterFrequency(selectedPreset->getCenterFrequency());
*response.getGroupName() = selectedPreset->getGroup();
*response.getType() = selectedPreset->isSourcePreset() ? "R" : "T";
@@ -576,6 +585,7 @@ int WebAPIAdapterGUI::instanceDeviceSetPost(
MainWindow::MsgAddDeviceSet *msg = MainWindow::MsgAddDeviceSet::create(tx);
m_mainWindow.m_inputMessageQueue.push(msg);
response.init();
*response.getMessage() = QString("Message to add a new device set (MsgAddDeviceSet) was submitted successfully");
return 202;
@@ -590,12 +600,14 @@ int WebAPIAdapterGUI::instanceDeviceSetDelete(
MainWindow::MsgRemoveLastDeviceSet *msg = MainWindow::MsgRemoveLastDeviceSet::create();
m_mainWindow.m_inputMessageQueue.push(msg);
response.init();
*response.getMessage() = QString("Message to remove last device set (MsgRemoveLastDeviceSet) was submitted successfully");
return 202;
}
else
{
error.init();
*error.getMessage() = "No more device sets to be removed";
return 404;
@@ -616,6 +628,7 @@ int WebAPIAdapterGUI::devicesetGet(
}
else
{
error.init();
*error.getMessage() = QString("There is no device set with index %1").arg(deviceSetIndex);
return 404;
@@ -632,12 +645,14 @@ int WebAPIAdapterGUI::devicesetFocusPatch(
MainWindow::MsgDeviceSetFocus *msg = MainWindow::MsgDeviceSetFocus::create(deviceSetIndex);
m_mainWindow.m_inputMessageQueue.push(msg);
response.init();
*response.getMessage() = QString("Message to focus on device set (MsgDeviceSetFocus) was submitted successfully");
return 202;
}
else
{
error.init();
*error.getMessage() = QString("There is no device set with index %1").arg(deviceSetIndex);
return 404;
@@ -695,6 +710,7 @@ int WebAPIAdapterGUI::devicesetDevicePut(
MainWindow::MsgSetDevice *msg = MainWindow::MsgSetDevice::create(deviceSetIndex, i, response.getTx() != 0);
m_mainWindow.m_inputMessageQueue.push(msg);
response.init();
*response.getDisplayedName() = samplingDevice.displayedName;
*response.getHwType() = samplingDevice.hardwareId;
*response.getSerial() = samplingDevice.serial;
@@ -713,6 +729,7 @@ int WebAPIAdapterGUI::devicesetDevicePut(
}
else
{
error.init();
*error.getMessage() = QString("There is no device set with index %1").arg(deviceSetIndex);
return 404;
@@ -744,12 +761,14 @@ int WebAPIAdapterGUI::devicesetDeviceSettingsGet(
}
else
{
error.init();
*error.getMessage() = QString("DeviceSet error");
return 500;
}
}
else
{
error.init();
*error.getMessage() = QString("There is no device set with index %1").arg(deviceSetIndex);
return 404;
@@ -805,12 +824,14 @@ int WebAPIAdapterGUI::devicesetDeviceSettingsPutPatch(
}
else
{
error.init();
*error.getMessage() = QString("DeviceSet error");
return 500;
}
}
else
{
error.init();
*error.getMessage() = QString("There is no device set with index %1").arg(deviceSetIndex);
return 404;
@@ -838,12 +859,14 @@ int WebAPIAdapterGUI::devicesetDeviceRunGet(
}
else
{
error.init();
*error.getMessage() = QString("DeviceSet error");
return 500;
}
}
else
{
error.init();
*error.getMessage() = QString("There is no device set with index %1").arg(deviceSetIndex);
return 404;
@@ -871,12 +894,14 @@ int WebAPIAdapterGUI::devicesetDeviceRunPost(
}
else
{
error.init();
*error.getMessage() = QString("DeviceSet error");
return 500;
}
}
else
{
error.init();
*error.getMessage() = QString("There is no device set with index %1").arg(deviceSetIndex);
return 404;
@@ -904,12 +929,14 @@ int WebAPIAdapterGUI::devicesetDeviceRunDelete(
}
else
{
error.init();
*error.getMessage() = QString("DeviceSet error");
return 500;
}
}
else
{
error.init();
*error.getMessage() = QString("There is no device set with index %1").arg(deviceSetIndex);
return 404;
@@ -930,6 +957,7 @@ int WebAPIAdapterGUI::devicesetChannelPost(
{
if (deviceSet->m_deviceSourceEngine == 0)
{
error.init();
*error.getMessage() = QString("Device set at %1 is not a receive device set").arg(deviceSetIndex);
return 400;
}
@@ -949,12 +977,14 @@ int WebAPIAdapterGUI::devicesetChannelPost(
MainWindow::MsgAddChannel *msg = MainWindow::MsgAddChannel::create(deviceSetIndex, index, false);
m_mainWindow.m_inputMessageQueue.push(msg);
response.init();
*response.getMessage() = QString("Message to add a channel (MsgAddChannel) was submitted successfully");
return 202;
}
else
{
error.init();
*error.getMessage() = QString("There is no receive channel with id %1").arg(*query.getChannelType());
return 404;
}
@@ -963,6 +993,7 @@ int WebAPIAdapterGUI::devicesetChannelPost(
{
if (deviceSet->m_deviceSinkEngine == 0)
{
error.init();
*error.getMessage() = QString("Device set at %1 is not a transmit device set").arg(deviceSetIndex);
return 400;
}
@@ -982,12 +1013,14 @@ int WebAPIAdapterGUI::devicesetChannelPost(
MainWindow::MsgAddChannel *msg = MainWindow::MsgAddChannel::create(deviceSetIndex, index, true);
m_mainWindow.m_inputMessageQueue.push(msg);
response.init();
*response.getMessage() = QString("Message to add a channel (MsgAddChannel) was submitted successfully");
return 202;
}
else
{
error.init();
*error.getMessage() = QString("There is no transmit channel with id %1").arg(*query.getChannelType());
return 404;
}
@@ -995,6 +1028,7 @@ int WebAPIAdapterGUI::devicesetChannelPost(
}
else
{
error.init();
*error.getMessage() = QString("There is no device set with index %1").arg(deviceSetIndex);
return 404;
}
@@ -1017,12 +1051,14 @@ int WebAPIAdapterGUI::devicesetChannelDelete(
MainWindow::MsgDeleteChannel *msg = MainWindow::MsgDeleteChannel::create(deviceSetIndex, channelIndex, false);
m_mainWindow.m_inputMessageQueue.push(msg);
response.init();
*response.getMessage() = QString("Message to delete a channel (MsgDeleteChannel) was submitted successfully");
return 202;
}
else
{
error.init();
*error.getMessage() = QString("There is no channel at index %1. There are %2 Rx channels")
.arg(channelIndex)
.arg(channelIndex < deviceSet->getNumberOfRxChannels());
@@ -1036,12 +1072,14 @@ int WebAPIAdapterGUI::devicesetChannelDelete(
MainWindow::MsgDeleteChannel *msg = MainWindow::MsgDeleteChannel::create(deviceSetIndex, channelIndex, true);
m_mainWindow.m_inputMessageQueue.push(msg);
response.init();
*response.getMessage() = QString("Message to delete a channel (MsgDeleteChannel) was submitted successfully");
return 202;
}
else
{
error.init();
*error.getMessage() = QString("There is no channel at index %1. There are %2 Tx channels")
.arg(channelIndex)
.arg(channelIndex < deviceSet->getNumberOfRxChannels());
@@ -1050,12 +1088,14 @@ int WebAPIAdapterGUI::devicesetChannelDelete(
}
else
{
error.init();
*error.getMessage() = QString("DeviceSet error");
return 500;
}
}
else
{
error.init();
*error.getMessage() = QString("There is no device set with index %1").arg(deviceSetIndex);
return 404;
}
@@ -1077,6 +1117,7 @@ int WebAPIAdapterGUI::devicesetChannelSettingsGet(
if (channelAPI == 0)
{
error.init();
*error.getMessage() = QString("There is no channel with index %1").arg(channelIndex);
return 404;
}
@@ -1094,6 +1135,7 @@ int WebAPIAdapterGUI::devicesetChannelSettingsGet(
if (channelAPI == 0)
{
error.init();
*error.getMessage() = QString("There is no channel with index %1").arg(channelIndex);
return 404;
}
@@ -1107,12 +1149,14 @@ int WebAPIAdapterGUI::devicesetChannelSettingsGet(
}
else
{
error.init();
*error.getMessage() = QString("DeviceSet error");
return 500;
}
}
else
{
error.init();
*error.getMessage() = QString("There is no device set with index %1").arg(deviceSetIndex);
return 404;
}
@@ -1136,6 +1180,7 @@ int WebAPIAdapterGUI::devicesetChannelSettingsPutPatch(
if (channelAPI == 0)
{
error.init();
*error.getMessage() = QString("There is no channel with index %1").arg(channelIndex);
return 404;
}
@@ -1150,6 +1195,7 @@ int WebAPIAdapterGUI::devicesetChannelSettingsPutPatch(
}
else
{
error.init();
*error.getMessage() = QString("There is no channel type %1 at index %2. Found %3.")
.arg(*response.getChannelType())
.arg(channelIndex)
@@ -1164,6 +1210,7 @@ int WebAPIAdapterGUI::devicesetChannelSettingsPutPatch(
if (channelAPI == 0)
{
error.init();
*error.getMessage() = QString("There is no channel with index %1").arg(channelIndex);
return 404;
}
@@ -1178,6 +1225,7 @@ int WebAPIAdapterGUI::devicesetChannelSettingsPutPatch(
}
else
{
error.init();
*error.getMessage() = QString("There is no channel type %1 at index %2. Found %3.")
.arg(*response.getChannelType())
.arg(channelIndex)
@@ -1188,12 +1236,14 @@ int WebAPIAdapterGUI::devicesetChannelSettingsPutPatch(
}
else
{
error.init();
*error.getMessage() = QString("DeviceSet error");
return 500;
}
}
else
{
error.init();
*error.getMessage() = QString("There is no device set with index %1").arg(deviceSetIndex);
return 404;
@@ -1203,6 +1253,7 @@ int WebAPIAdapterGUI::devicesetChannelSettingsPutPatch(
void WebAPIAdapterGUI::getDeviceSetList(SWGSDRangel::SWGDeviceSetList* deviceSetList)
{
deviceSetList->init();
deviceSetList->setDevicesetcount((int) m_mainWindow.m_deviceUIs.size());
if (m_mainWindow.m_deviceUIs.size() > 0) {
@@ -1223,6 +1274,7 @@ void WebAPIAdapterGUI::getDeviceSetList(SWGSDRangel::SWGDeviceSetList* deviceSet
void WebAPIAdapterGUI::getDeviceSet(SWGSDRangel::SWGDeviceSet *deviceSet, const DeviceUISet* deviceUISet, int deviceUISetIndex)
{
SWGSDRangel::SWGSamplingDevice *samplingDevice = deviceSet->getSamplingDevice();
samplingDevice->init();
samplingDevice->setIndex(deviceUISetIndex);
samplingDevice->setTx(deviceUISet->m_deviceSinkEngine != 0);