Skip to content

Commit

Permalink
DeviceSet and DeviceUISet: use delete channel API instead of destroy …
Browse files Browse the repository at this point in the history
…method so that the virtual destructor of the channel is called appropriately
  • Loading branch information
f4exb committed Aug 27, 2024
1 parent aca4a53 commit 7b4e751
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 13 deletions.
10 changes: 5 additions & 5 deletions sdrbase/device/deviceset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);

Expand Down
4 changes: 1 addition & 3 deletions sdrbase/device/deviceset.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,7 @@ class SDRBASE_API DeviceSet
int webapiSpectrumServerDelete(SWGSDRangel::SWGSuccessResponse& response, QString& errorMessage);

private:
typedef QList<ChannelAPI*> ChannelInstanceRegistrations;

ChannelInstanceRegistrations m_channelInstanceRegistrations;
QList<ChannelAPI*> m_channelInstanceRegistrations;
int m_deviceTabIndex;

void renameChannelInstances();
Expand Down
10 changes: 5 additions & 5 deletions sdrgui/device/deviceuiset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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);
}

Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 7b4e751

Please sign in to comment.