1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-22 08:04:49 -05:00

DeviceSet and DeviceUISet: use delete channel API instead of destroy method so that the virtual destructor of the channel is called appropriately

This commit is contained in:
f4exb 2024-08-19 00:31:55 +02:00 committed by Edouard Griffiths
parent aca4a53513
commit 7b4e751ba1
3 changed files with 11 additions and 13 deletions

View File

@ -59,7 +59,7 @@ void DeviceSet::freeChannels()
for(int i = 0; i < m_channelInstanceRegistrations.count(); i++)
{
qDebug("DeviceSet::freeChannels: destroying channel [%s]", qPrintable(m_channelInstanceRegistrations[i]->getURI()));
m_channelInstanceRegistrations[i]->destroy();
delete m_channelInstanceRegistrations[i];
}
MainCore::instance()->clearChannels(this);
@ -87,7 +87,7 @@ void DeviceSet::deleteChannel(int channelIndex)
{
if (channelIndex < m_channelInstanceRegistrations.count())
{
m_channelInstanceRegistrations[channelIndex]->destroy();
delete m_channelInstanceRegistrations[channelIndex];
m_channelInstanceRegistrations.removeAt(channelIndex);
MainCore::instance()->removeChannelInstanceAt(this, channelIndex);
renameChannelInstances();
@ -141,7 +141,7 @@ void DeviceSet::loadRxChannelSettings(const Preset *preset, PluginAPI *pluginAPI
PluginAPI::ChannelRegistrations *channelRegistrations = pluginAPI->getRxChannelRegistrations();
// copy currently open channels and clear list
ChannelInstanceRegistrations openChannels = m_channelInstanceRegistrations;
QList<ChannelAPI*> openChannels = m_channelInstanceRegistrations;
m_channelInstanceRegistrations.clear();
mainCore->clearChannels(this);
@ -241,7 +241,7 @@ void DeviceSet::loadTxChannelSettings(const Preset *preset, PluginAPI *pluginAPI
PluginAPI::ChannelRegistrations *channelRegistrations = pluginAPI->getTxChannelRegistrations();
// copy currently open channels and clear list
ChannelInstanceRegistrations openChannels = m_channelInstanceRegistrations;
QList<ChannelAPI*> openChannels = m_channelInstanceRegistrations;
m_channelInstanceRegistrations.clear();
mainCore->clearChannels(this);
@ -339,7 +339,7 @@ void DeviceSet::loadMIMOChannelSettings(const Preset *preset, PluginAPI *pluginA
PluginAPI::ChannelRegistrations *channelRegistrations = pluginAPI->getMIMOChannelRegistrations();
// copy currently open channels and clear list
ChannelInstanceRegistrations openChannels = m_channelInstanceRegistrations;
QList<ChannelAPI*> openChannels = m_channelInstanceRegistrations;
m_channelInstanceRegistrations.clear();
mainCore->clearChannels(this);

View File

@ -86,9 +86,7 @@ public:
int webapiSpectrumServerDelete(SWGSDRangel::SWGSuccessResponse& response, QString& errorMessage);
private:
typedef QList<ChannelAPI*> ChannelInstanceRegistrations;
ChannelInstanceRegistrations m_channelInstanceRegistrations;
QList<ChannelAPI*> m_channelInstanceRegistrations;
int m_deviceTabIndex;
void renameChannelInstances();

View File

@ -170,7 +170,7 @@ void DeviceUISet::freeChannels()
{
qDebug("DeviceUISet::freeChannels: destroying channel [%s]", qPrintable(m_channelInstanceRegistrations[i].m_channelAPI->getURI()));
m_channelInstanceRegistrations[i].m_gui->destroy();
m_channelInstanceRegistrations[i].m_channelAPI->destroy();
delete m_channelInstanceRegistrations[i].m_channelAPI;
}
m_channelInstanceRegistrations.clear();
@ -185,7 +185,7 @@ void DeviceUISet::deleteChannel(int channelIndex)
qPrintable(m_channelInstanceRegistrations[channelIndex].m_channelAPI->getURI()),
channelIndex);
m_channelInstanceRegistrations[channelIndex].m_gui->destroy();
m_channelInstanceRegistrations[channelIndex].m_channelAPI->destroy();
delete m_channelInstanceRegistrations[channelIndex].m_channelAPI;
m_channelInstanceRegistrations.removeAt(channelIndex);
}
@ -324,7 +324,7 @@ void DeviceUISet::loadRxChannelSettings(const Preset *preset, PluginAPI *pluginA
qPrintable(m_channelInstanceRegistrations[i].m_channelAPI->getURI()));
m_channelInstanceRegistrations[i].m_channelAPI->setMessageQueueToGUI(nullptr); // have channel stop sending messages to its GUI
m_channelInstanceRegistrations[i].m_gui->destroy();
m_channelInstanceRegistrations[i].m_channelAPI->destroy();
delete m_channelInstanceRegistrations[i].m_channelAPI;
}
m_channelInstanceRegistrations.clear();
@ -453,7 +453,7 @@ void DeviceUISet::loadTxChannelSettings(const Preset *preset, PluginAPI *pluginA
qPrintable(m_channelInstanceRegistrations[i].m_channelAPI->getURI()));
m_channelInstanceRegistrations[i].m_channelAPI->setMessageQueueToGUI(nullptr); // have channel stop sending messages to its GUI
m_channelInstanceRegistrations[i].m_gui->destroy();
m_channelInstanceRegistrations[i].m_channelAPI->destroy();
delete m_channelInstanceRegistrations[i].m_channelAPI;
}
m_channelInstanceRegistrations.clear();
@ -579,7 +579,7 @@ void DeviceUISet::loadMIMOChannelSettings(const Preset *preset, PluginAPI *plugi
qDebug("DeviceUISet::loadMIMOChannelSettings: destroying old channel [%s]",
qPrintable(m_channelInstanceRegistrations[i].m_channelAPI->getURI()));
m_channelInstanceRegistrations[i].m_gui->destroy(); // stop GUI first (issue #1427)
m_channelInstanceRegistrations[i].m_channelAPI->destroy(); // stop channel before (issue #860)
delete m_channelInstanceRegistrations[i].m_channelAPI; // stop channel before (issue #860)
}
m_channelInstanceRegistrations.clear();