1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-09-27 15:26:33 -04:00

Delete channel API from DeviceUISet. Update FeatureUISet

This commit is contained in:
f4exb 2020-10-04 19:07:42 +02:00
parent e9a32528d7
commit 6ebf4569bf
51 changed files with 138 additions and 193 deletions

View File

@ -424,7 +424,6 @@ ChannelAnalyzerGUI::ChannelAnalyzerGUI(PluginAPI* pluginAPI, DeviceUISet *device
ChannelAnalyzerGUI::~ChannelAnalyzerGUI() ChannelAnalyzerGUI::~ChannelAnalyzerGUI()
{ {
delete m_channelAnalyzer; // TODO: check this: when the GUI closes it has to delete the demodulator
delete m_scopeVis; delete m_scopeVis;
delete m_spectrumScopeComboVis; delete m_spectrumScopeComboVis;
delete ui; delete ui;

View File

@ -64,6 +64,7 @@ AMDemod::AMDemod(DeviceAPI *deviceAPI) :
AMDemod::~AMDemod() AMDemod::~AMDemod()
{ {
qDebug("AMDemod::~AMDemod");
disconnect(m_networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(networkManagerFinished(QNetworkReply*))); disconnect(m_networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(networkManagerFinished(QNetworkReply*)));
delete m_networkManager; delete m_networkManager;
m_deviceAPI->removeChannelSinkAPI(this); m_deviceAPI->removeChannelSinkAPI(this);

View File

@ -62,7 +62,7 @@ public:
}; };
AMDemod(DeviceAPI *deviceAPI); AMDemod(DeviceAPI *deviceAPI);
~AMDemod(); virtual ~AMDemod();
virtual void destroy() { delete this; } virtual void destroy() { delete this; }
virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool po); virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool po);

View File

@ -289,7 +289,6 @@ AMDemodGUI::AMDemodGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, BasebandS
AMDemodGUI::~AMDemodGUI() AMDemodGUI::~AMDemodGUI()
{ {
delete m_amDemod; // TODO: check this: when the GUI closes it has to delete the demodulator
delete ui; delete ui;
} }

View File

@ -61,7 +61,7 @@ public:
}; };
ATVDemod(DeviceAPI *deviceAPI); ATVDemod(DeviceAPI *deviceAPI);
~ATVDemod(); virtual ~ATVDemod();
virtual void destroy() { delete this; } virtual void destroy() { delete this; }
virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool po); virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool po);

View File

@ -275,7 +275,6 @@ ATVDemodGUI::ATVDemodGUI(PluginAPI* objPluginAPI, DeviceUISet *deviceUISet, Base
ATVDemodGUI::~ATVDemodGUI() ATVDemodGUI::~ATVDemodGUI()
{ {
delete m_atvDemod; // TODO: check this: when the GUI closes it has to delete the demodulator
delete m_scopeVis; delete m_scopeVis;
delete ui; delete ui;
} }

View File

@ -420,7 +420,6 @@ BFMDemodGUI::BFMDemodGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, Baseban
BFMDemodGUI::~BFMDemodGUI() BFMDemodGUI::~BFMDemodGUI()
{ {
delete m_bfmDemod; // TODO: check this: when the GUI closes it has to delete the demodulator
delete ui; delete ui;
} }

View File

@ -38,7 +38,7 @@ class DATVDemod : public BasebandSampleSink, public ChannelAPI
public: public:
DATVDemod(DeviceAPI *); DATVDemod(DeviceAPI *);
~DATVDemod(); virtual ~DATVDemod();
virtual void destroy() { delete this; } virtual void destroy() { delete this; }
virtual void getIdentifier(QString& id) { id = m_channelId; } virtual void getIdentifier(QString& id) { id = m_channelId; }

View File

@ -244,7 +244,6 @@ DATVDemodGUI::DATVDemodGUI(PluginAPI* objPluginAPI, DeviceUISet *deviceUISet, Ba
DATVDemodGUI::~DATVDemodGUI() DATVDemodGUI::~DATVDemodGUI()
{ {
delete m_objDATVDemod;
delete ui; delete ui;
} }

View File

@ -63,7 +63,7 @@ public:
}; };
DSDDemod(DeviceAPI *deviceAPI); DSDDemod(DeviceAPI *deviceAPI);
~DSDDemod(); virtual ~DSDDemod();
virtual void destroy() { delete this; } virtual void destroy() { delete this; }
virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool po); virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool po);

View File

@ -381,7 +381,6 @@ DSDDemodGUI::DSDDemodGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, Baseban
DSDDemodGUI::~DSDDemodGUI() DSDDemodGUI::~DSDDemodGUI()
{ {
delete m_dsdDemod; // TODO: check this: when the GUI closes it has to delete the demodulator
delete m_scopeVisXY; delete m_scopeVisXY;
delete ui; delete ui;
} }

View File

@ -308,7 +308,6 @@ FreeDVDemodGUI::FreeDVDemodGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, B
FreeDVDemodGUI::~FreeDVDemodGUI() FreeDVDemodGUI::~FreeDVDemodGUI()
{ {
delete m_freeDVDemod; // TODO: check this: when the GUI closes it has to delete the demodulator
delete ui; delete ui;
} }

View File

@ -147,8 +147,6 @@ LoRaDemodGUI::LoRaDemodGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, Baseb
LoRaDemodGUI::~LoRaDemodGUI() LoRaDemodGUI::~LoRaDemodGUI()
{ {
m_deviceUISet->removeRxChannelInstance(this);
delete m_LoRaDemod; // TODO: check this: when the GUI closes it has to delete the demodulator
delete ui; delete ui;
} }

View File

@ -62,7 +62,7 @@ public:
}; };
NFMDemod(DeviceAPI *deviceAPI); NFMDemod(DeviceAPI *deviceAPI);
~NFMDemod(); virtual ~NFMDemod();
virtual void destroy() { delete this; } virtual void destroy() { delete this; }
virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool positive); virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool positive);

View File

@ -333,7 +333,6 @@ NFMDemodGUI::NFMDemodGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, Baseban
NFMDemodGUI::~NFMDemodGUI() NFMDemodGUI::~NFMDemodGUI()
{ {
delete m_nfmDemod; // TODO: check this: when the GUI closes it has to delete the demodulator
delete ui; delete ui;
} }

View File

@ -342,7 +342,6 @@ SSBDemodGUI::SSBDemodGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, Baseban
SSBDemodGUI::~SSBDemodGUI() SSBDemodGUI::~SSBDemodGUI()
{ {
delete m_ssbDemod; // TODO: check this: when the GUI closes it has to delete the demodulator
delete ui; delete ui;
} }

View File

@ -246,8 +246,6 @@ WFMDemodGUI::WFMDemodGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, Baseban
WFMDemodGUI::~WFMDemodGUI() WFMDemodGUI::~WFMDemodGUI()
{ {
delete m_wfmDemod; // TODO: check this: when the GUI closes it has to delete the demodulator
//delete m_channelMarker;
delete ui; delete ui;
} }

View File

@ -198,7 +198,6 @@ FileSinkGUI::FileSinkGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, Baseban
FileSinkGUI::~FileSinkGUI() FileSinkGUI::~FileSinkGUI()
{ {
delete m_fileSink; // TODO: check this: when the GUI closes it has to delete the demodulator
delete ui; delete ui;
} }

View File

@ -60,7 +60,7 @@ public:
}; };
FreqTracker(DeviceAPI *deviceAPI); FreqTracker(DeviceAPI *deviceAPI);
~FreqTracker(); virtual ~FreqTracker();
virtual void destroy() { delete this; } virtual void destroy() { delete this; }
virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool po); virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool po);

View File

@ -332,7 +332,6 @@ FreqTrackerGUI::FreqTrackerGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, B
FreqTrackerGUI::~FreqTrackerGUI() FreqTrackerGUI::~FreqTrackerGUI()
{ {
delete m_freqTracker; // TODO: check this: when the GUI closes it has to delete the demodulator
delete ui; delete ui;
} }

View File

@ -130,7 +130,6 @@ LocalSinkGUI::LocalSinkGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, Baseb
LocalSinkGUI::~LocalSinkGUI() LocalSinkGUI::~LocalSinkGUI()
{ {
delete m_localSink; // TODO: check this: when the GUI closes it has to delete the demodulator
delete ui; delete ui;
} }

View File

@ -129,7 +129,6 @@ RemoteSinkGUI::RemoteSinkGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, Bas
RemoteSinkGUI::~RemoteSinkGUI() RemoteSinkGUI::~RemoteSinkGUI()
{ {
delete m_remoteSink; // TODO: check this: when the GUI closes it has to delete the demodulator
delete ui; delete ui;
} }

View File

@ -209,7 +209,6 @@ UDPSinkGUI::UDPSinkGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, BasebandS
UDPSinkGUI::~UDPSinkGUI() UDPSinkGUI::~UDPSinkGUI()
{ {
delete m_udpSink; // TODO: check this: when the GUI closes it has to delete the demodulator
delete ui; delete ui;
} }

View File

@ -166,7 +166,7 @@ public:
}; };
FileSource(DeviceAPI *deviceAPI); FileSource(DeviceAPI *deviceAPI);
~FileSource(); virtual ~FileSource();
virtual void destroy() { delete this; } virtual void destroy() { delete this; }
virtual void start(); virtual void start();

View File

@ -216,7 +216,6 @@ FileSourceGUI::FileSourceGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, Bas
FileSourceGUI::~FileSourceGUI() FileSourceGUI::~FileSourceGUI()
{ {
delete m_fileSource;
delete ui; delete ui;
} }

View File

@ -125,7 +125,6 @@ LocalSourceGUI::LocalSourceGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, B
LocalSourceGUI::~LocalSourceGUI() LocalSourceGUI::~LocalSourceGUI()
{ {
delete m_localSource; // TODO: check this: when the GUI closes it has to delete the demodulator
delete ui; delete ui;
} }

View File

@ -173,7 +173,7 @@ public:
//================================================================= //=================================================================
AMMod(DeviceAPI *deviceAPI); AMMod(DeviceAPI *deviceAPI);
~AMMod(); virtual ~AMMod();
virtual void destroy() { delete this; } virtual void destroy() { delete this; }
virtual void start(); virtual void start();

View File

@ -385,7 +385,6 @@ AMModGUI::AMModGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, BasebandSampl
AMModGUI::~AMModGUI() AMModGUI::~AMModGUI()
{ {
delete m_amMod; // TODO: check this: when the GUI closes it has to delete the modulator
delete ui; delete ui;
} }

View File

@ -245,7 +245,7 @@ public:
//================================================================= //=================================================================
ATVMod(DeviceAPI *deviceAPI); ATVMod(DeviceAPI *deviceAPI);
~ATVMod(); virtual ~ATVMod();
virtual void destroy() { delete this; } virtual void destroy() { delete this; }
virtual void start(); virtual void start();

View File

@ -116,7 +116,6 @@ ATVModGUI::ATVModGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, BasebandSam
ATVModGUI::~ATVModGUI() ATVModGUI::~ATVModGUI()
{ {
delete m_atvMod; // TODO: check this: when the GUI closes it has to delete the modulator
delete ui; delete ui;
} }

View File

@ -177,7 +177,7 @@ public:
//================================================================= //=================================================================
FreeDVMod(DeviceAPI *deviceAPI); FreeDVMod(DeviceAPI *deviceAPI);
~FreeDVMod(); virtual ~FreeDVMod();
virtual void destroy() { delete this; } virtual void destroy() { delete this; }
virtual void start(); virtual void start();

View File

@ -396,7 +396,6 @@ FreeDVModGUI::FreeDVModGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, Baseb
FreeDVModGUI::~FreeDVModGUI() FreeDVModGUI::~FreeDVModGUI()
{ {
delete m_freeDVMod; // TODO: check this: when the GUI closes it has to delete the modulator
delete ui; delete ui;
} }

View File

@ -173,7 +173,7 @@ public:
//================================================================= //=================================================================
NFMMod(DeviceAPI *deviceAPI); NFMMod(DeviceAPI *deviceAPI);
~NFMMod(); virtual ~NFMMod();
virtual void destroy() { delete this; } virtual void destroy() { delete this; }
virtual void start(); virtual void start();

View File

@ -418,7 +418,6 @@ NFMModGUI::NFMModGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, BasebandSam
NFMModGUI::~NFMModGUI() NFMModGUI::~NFMModGUI()
{ {
delete m_nfmMod; // TODO: check this: when the GUI closes it has to delete the modulator
delete ui; delete ui;
} }

View File

@ -94,7 +94,7 @@ public:
//================================================================= //=================================================================
PacketMod(DeviceAPI *deviceAPI); PacketMod(DeviceAPI *deviceAPI);
~PacketMod(); virtual ~PacketMod();
virtual void destroy() { delete this; } virtual void destroy() { delete this; }
virtual void start(); virtual void start();

View File

@ -465,7 +465,6 @@ PacketModGUI::PacketModGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, Baseb
PacketModGUI::~PacketModGUI() PacketModGUI::~PacketModGUI()
{ {
delete m_packetMod; // TODO: check this: when the GUI closes it has to delete the modulator
delete ui; delete ui;
} }

View File

@ -175,7 +175,7 @@ public:
//================================================================= //=================================================================
SSBMod(DeviceAPI *deviceAPI); SSBMod(DeviceAPI *deviceAPI);
~SSBMod(); virtual ~SSBMod();
virtual void destroy() { delete this; } virtual void destroy() { delete this; }
virtual void start(); virtual void start();

View File

@ -464,7 +464,6 @@ SSBModGUI::SSBModGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, BasebandSam
SSBModGUI::~SSBModGUI() SSBModGUI::~SSBModGUI()
{ {
delete m_ssbMod; // TODO: check this: when the GUI closes it has to delete the modulator
delete ui; delete ui;
} }

View File

@ -173,7 +173,7 @@ public:
//================================================================= //=================================================================
WFMMod(DeviceAPI *deviceAPI); WFMMod(DeviceAPI *deviceAPI);
~WFMMod(); virtual ~WFMMod();
virtual void destroy() { delete this; } virtual void destroy() { delete this; }
virtual void start(); virtual void start();

View File

@ -402,7 +402,6 @@ WFMModGUI::WFMModGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, BasebandSam
WFMModGUI::~WFMModGUI() WFMModGUI::~WFMModGUI()
{ {
delete m_wfmMod; // TODO: check this: when the GUI closes it has to delete the modulator
delete ui; delete ui;
} }

View File

@ -155,7 +155,7 @@ public:
}; };
RemoteSource(DeviceAPI *deviceAPI); RemoteSource(DeviceAPI *deviceAPI);
~RemoteSource(); virtual ~RemoteSource();
virtual void destroy() { delete this; } virtual void destroy() { delete this; }

View File

@ -190,7 +190,6 @@ RemoteSourceGUI::RemoteSourceGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet,
RemoteSourceGUI::~RemoteSourceGUI() RemoteSourceGUI::~RemoteSourceGUI()
{ {
delete m_remoteSrc;
delete ui; delete ui;
} }

View File

@ -163,7 +163,6 @@ UDPSourceGUI::UDPSourceGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, Baseb
UDPSourceGUI::~UDPSourceGUI() UDPSourceGUI::~UDPSourceGUI()
{ {
delete m_udpSource; // TODO: check this: when the GUI closes it has to delete the modulator
delete ui; delete ui;
} }

View File

@ -82,7 +82,7 @@ public:
}; };
RigCtlServer(WebAPIAdapterInterface *webAPIAdapterInterface); RigCtlServer(WebAPIAdapterInterface *webAPIAdapterInterface);
~RigCtlServer(); virtual ~RigCtlServer();
virtual void destroy() { delete this; } virtual void destroy() { delete this; }
virtual bool handleMessage(const Message& cmd); virtual bool handleMessage(const Message& cmd);

View File

@ -100,7 +100,7 @@ public:
}; };
SimplePTT(WebAPIAdapterInterface *webAPIAdapterInterface); SimplePTT(WebAPIAdapterInterface *webAPIAdapterInterface);
~SimplePTT(); virtual ~SimplePTT();
virtual void destroy() { delete this; } virtual void destroy() { delete this; }
virtual bool handleMessage(const Message& cmd); virtual bool handleMessage(const Message& cmd);

View File

@ -94,63 +94,49 @@ void DeviceUISet::addRollupWidget(QWidget *widget)
m_channelWindow->addRollupWidget(widget); m_channelWindow->addRollupWidget(widget);
} }
void DeviceUISet::registerRxChannelInstance(const QString& channelName, ChannelAPI *channelAPI, ChannelGUI* pluginGUI) void DeviceUISet::registerRxChannelInstance(const QString& channelName, ChannelAPI *channelAPI, ChannelGUI* channelGUI)
{ {
m_channelInstanceRegistrations.append(ChannelInstanceRegistration(channelName, channelAPI, pluginGUI, 0)); m_channelInstanceRegistrations.append(ChannelInstanceRegistration(channelName, channelAPI, channelGUI, 0));
QObject::connect(
channelGUI,
&ChannelGUI::closing,
this,
[=](){ this->handleChannelGUIClosing(channelGUI); },
Qt::QueuedConnection
);
} }
void DeviceUISet::registerTxChannelInstance(const QString& channelName, ChannelAPI *channelAPI, ChannelGUI* pluginGUI) void DeviceUISet::registerTxChannelInstance(const QString& channelName, ChannelAPI *channelAPI, ChannelGUI* channelGUI)
{ {
m_channelInstanceRegistrations.append(ChannelInstanceRegistration(channelName, channelAPI, pluginGUI, 1)); m_channelInstanceRegistrations.append(ChannelInstanceRegistration(channelName, channelAPI, channelGUI, 1));
QObject::connect(
channelGUI,
&ChannelGUI::closing,
this,
[=](){ this->handleChannelGUIClosing(channelGUI); },
Qt::QueuedConnection
);
} }
void DeviceUISet::registerChannelInstance(const QString& channelName, ChannelAPI *channelAPI, ChannelGUI* pluginGUI) void DeviceUISet::registerChannelInstance(const QString& channelName, ChannelAPI *channelAPI, ChannelGUI* channelGUI)
{ {
m_channelInstanceRegistrations.append(ChannelInstanceRegistration(channelName, channelAPI, pluginGUI, 2)); m_channelInstanceRegistrations.append(ChannelInstanceRegistration(channelName, channelAPI, channelGUI, 2));
} QObject::connect(
channelGUI,
void DeviceUISet::removeRxChannelInstance(ChannelGUI* pluginGUI) &ChannelGUI::closing,
{ this,
for (ChannelInstanceRegistrations::iterator it = m_channelInstanceRegistrations.begin(); it != m_channelInstanceRegistrations.end(); ++it) [=](){ this->handleChannelGUIClosing(channelGUI); },
{ Qt::QueuedConnection
if (it->m_gui == pluginGUI) );
{
m_channelInstanceRegistrations.erase(it);
break;
}
}
}
void DeviceUISet::removeTxChannelInstance(ChannelGUI* pluginGUI)
{
for (ChannelInstanceRegistrations::iterator it = m_channelInstanceRegistrations.begin(); it != m_channelInstanceRegistrations.end(); ++it)
{
if (it->m_gui == pluginGUI)
{
m_channelInstanceRegistrations.erase(it);
break;
}
}
}
void DeviceUISet::removeChannelInstance(ChannelGUI* pluginGUI)
{
for (ChannelInstanceRegistrations::iterator it = m_channelInstanceRegistrations.begin(); it != m_channelInstanceRegistrations.end(); ++it)
{
if (it->m_gui == pluginGUI)
{
m_channelInstanceRegistrations.erase(it);
break;
}
}
} }
void DeviceUISet::freeChannels() void DeviceUISet::freeChannels()
{ {
for(int i = 0; i < m_channelInstanceRegistrations.count(); i++) for(int i = 0; i < m_channelInstanceRegistrations.count(); i++)
{ {
qDebug("DeviceUISet::freeChannels: destroying channel [%s]", qPrintable(m_channelInstanceRegistrations[i].m_channelName)); qDebug("DeviceUISet::freeChannels: destroying channel [%s]", qPrintable(m_channelInstanceRegistrations[i].m_channelURI));
m_channelInstanceRegistrations[i].m_gui->destroy(); m_channelInstanceRegistrations[i].m_gui->destroy();
m_channelInstanceRegistrations[i].m_channelAPI->destroy();
} }
} }
@ -159,9 +145,10 @@ void DeviceUISet::deleteChannel(int channelIndex)
if ((channelIndex >= 0) && (channelIndex < m_channelInstanceRegistrations.count())) if ((channelIndex >= 0) && (channelIndex < m_channelInstanceRegistrations.count()))
{ {
qDebug("DeviceUISet::deleteChannel: delete channel [%s] at %d", qDebug("DeviceUISet::deleteChannel: delete channel [%s] at %d",
qPrintable(m_channelInstanceRegistrations[channelIndex].m_channelName), qPrintable(m_channelInstanceRegistrations[channelIndex].m_channelURI),
channelIndex); channelIndex);
m_channelInstanceRegistrations[channelIndex].m_gui->destroy(); m_channelInstanceRegistrations[channelIndex].m_gui->destroy();
m_channelInstanceRegistrations[channelIndex].m_channelAPI->destroy();
} }
} }
@ -169,21 +156,22 @@ void DeviceUISet::loadRxChannelSettings(const Preset *preset, PluginAPI *pluginA
{ {
if (preset->isSourcePreset()) if (preset->isSourcePreset())
{ {
qDebug("DeviceUISet::loadRxChannelSettings: Loading preset [%s | %s]", qPrintable(preset->getGroup()), qPrintable(preset->getDescription())); qDebug("DeviceUISet::loadRxChannelSettings: Loading preset [%s | %s]",
qPrintable(preset->getGroup()), qPrintable(preset->getDescription()));
// Available channel plugins // Available channel plugins
PluginAPI::ChannelRegistrations *channelRegistrations = pluginAPI->getRxChannelRegistrations(); PluginAPI::ChannelRegistrations *channelRegistrations = pluginAPI->getRxChannelRegistrations();
// copy currently open channels and clear list // clear list
ChannelInstanceRegistrations openChannels = m_channelInstanceRegistrations; for(int i = 0; i < m_channelInstanceRegistrations.count(); i++)
m_channelInstanceRegistrations.clear();
for(int i = 0; i < openChannels.count(); i++)
{ {
qDebug("DeviceUISet::loadRxChannelSettings: destroying old channel [%s]", qPrintable(openChannels[i].m_channelName)); qDebug("DeviceUISet::loadRxChannelSettings: destroying old channel [%s]",
openChannels[i].m_gui->destroy(); // FIXME: stop channel before qPrintable(m_channelInstanceRegistrations[i].m_channelURI));
m_channelInstanceRegistrations[i].m_gui->destroy(); // FIXME: stop channel before
m_channelInstanceRegistrations[i].m_channelAPI->destroy();
} }
m_channelInstanceRegistrations.clear();
qDebug("DeviceUISet::loadRxChannelSettings: %d channel(s) in preset", preset->getChannelCount()); qDebug("DeviceUISet::loadRxChannelSettings: %d channel(s) in preset", preset->getChannelCount());
for (int i = 0; i < preset->getChannelCount(); i++) for (int i = 0; i < preset->getChannelCount(); i++)
@ -206,6 +194,13 @@ void DeviceUISet::loadRxChannelSettings(const Preset *preset, PluginAPI *pluginA
(*channelRegistrations)[i].m_plugin->createRxChannel(m_deviceAPI, &rxChannel, &channelAPI); (*channelRegistrations)[i].m_plugin->createRxChannel(m_deviceAPI, &rxChannel, &channelAPI);
rxChannelGUI = (*channelRegistrations)[i].m_plugin->createRxChannelGUI(this, rxChannel); rxChannelGUI = (*channelRegistrations)[i].m_plugin->createRxChannelGUI(this, rxChannel);
registerRxChannelInstance(channelAPI->getURI(), channelAPI, rxChannelGUI); registerRxChannelInstance(channelAPI->getURI(), channelAPI, rxChannelGUI);
QObject::connect(
rxChannelGUI,
&ChannelGUI::closing,
this,
[=](){ this->handleChannelGUIClosing(rxChannelGUI); },
Qt::QueuedConnection
);
break; break;
} }
} }
@ -231,8 +226,8 @@ void DeviceUISet::saveRxChannelSettings(Preset *preset)
for(int i = 0; i < m_channelInstanceRegistrations.count(); i++) for(int i = 0; i < m_channelInstanceRegistrations.count(); i++)
{ {
qDebug("DeviceUISet::saveRxChannelSettings: saving channel [%s]", qPrintable(m_channelInstanceRegistrations[i].m_channelName)); qDebug("DeviceUISet::saveRxChannelSettings: saving channel [%s]", qPrintable(m_channelInstanceRegistrations[i].m_channelURI));
preset->addChannel(m_channelInstanceRegistrations[i].m_channelName, m_channelInstanceRegistrations[i].m_gui->serialize()); preset->addChannel(m_channelInstanceRegistrations[i].m_channelURI, m_channelInstanceRegistrations[i].m_gui->serialize());
} }
} }
else else
@ -245,21 +240,22 @@ void DeviceUISet::loadTxChannelSettings(const Preset *preset, PluginAPI *pluginA
{ {
if (preset->isSinkPreset()) if (preset->isSinkPreset())
{ {
qDebug("DeviceUISet::loadTxChannelSettings: Loading preset [%s | %s]", qPrintable(preset->getGroup()), qPrintable(preset->getDescription())); qDebug("DeviceUISet::loadTxChannelSettings: Loading preset [%s | %s]",
qPrintable(preset->getGroup()), qPrintable(preset->getDescription()));
// Available channel plugins // Available channel plugins
PluginAPI::ChannelRegistrations *channelRegistrations = pluginAPI->getTxChannelRegistrations(); PluginAPI::ChannelRegistrations *channelRegistrations = pluginAPI->getTxChannelRegistrations();
// copy currently open channels and clear list // clear list
ChannelInstanceRegistrations openChannels = m_channelInstanceRegistrations; for(int i = 0; i < m_channelInstanceRegistrations.count(); i++)
m_channelInstanceRegistrations.clear();
for(int i = 0; i < openChannels.count(); i++)
{ {
qDebug("DeviceUISet::loadTxChannelSettings: destroying old channel [%s]", qPrintable(openChannels[i].m_channelName)); qDebug("DeviceUISet::loadTxChannelSettings: destroying old channel [%s]",
openChannels[i].m_gui->destroy(); qPrintable(m_channelInstanceRegistrations[i].m_channelURI));
m_channelInstanceRegistrations[i].m_gui->destroy();
m_channelInstanceRegistrations[i].m_channelAPI->destroy();
} }
m_channelInstanceRegistrations.clear();
qDebug("DeviceUISet::loadTxChannelSettings: %d channel(s) in preset", preset->getChannelCount()); qDebug("DeviceUISet::loadTxChannelSettings: %d channel(s) in preset", preset->getChannelCount());
for(int i = 0; i < preset->getChannelCount(); i++) for(int i = 0; i < preset->getChannelCount(); i++)
@ -281,6 +277,13 @@ void DeviceUISet::loadTxChannelSettings(const Preset *preset, PluginAPI *pluginA
(*channelRegistrations)[i].m_plugin->createTxChannel(m_deviceAPI, &txChannel, &channelAPI); (*channelRegistrations)[i].m_plugin->createTxChannel(m_deviceAPI, &txChannel, &channelAPI);
txChannelGUI = (*channelRegistrations)[i].m_plugin->createTxChannelGUI(this, txChannel); txChannelGUI = (*channelRegistrations)[i].m_plugin->createTxChannelGUI(this, txChannel);
registerTxChannelInstance(channelAPI->getURI(), channelAPI, txChannelGUI); registerTxChannelInstance(channelAPI->getURI(), channelAPI, txChannelGUI);
QObject::connect(
txChannelGUI,
&ChannelGUI::closing,
this,
[=](){ this->handleChannelGUIClosing(txChannelGUI); },
Qt::QueuedConnection
);
break; break;
} }
} }
@ -307,8 +310,8 @@ void DeviceUISet::saveTxChannelSettings(Preset *preset)
for(int i = 0; i < m_channelInstanceRegistrations.count(); i++) for(int i = 0; i < m_channelInstanceRegistrations.count(); i++)
{ {
qDebug("DeviceUISet::saveTxChannelSettings: saving channel [%s]", qPrintable(m_channelInstanceRegistrations[i].m_channelName)); qDebug("DeviceUISet::saveTxChannelSettings: saving channel [%s]", qPrintable(m_channelInstanceRegistrations[i].m_channelURI));
preset->addChannel(m_channelInstanceRegistrations[i].m_channelName, m_channelInstanceRegistrations[i].m_gui->serialize()); preset->addChannel(m_channelInstanceRegistrations[i].m_channelURI, m_channelInstanceRegistrations[i].m_gui->serialize());
} }
} }
else else
@ -321,21 +324,22 @@ void DeviceUISet::loadMIMOChannelSettings(const Preset *preset, PluginAPI *plugi
{ {
if (preset->isMIMOPreset()) if (preset->isMIMOPreset())
{ {
qDebug("DeviceUISet::loadMIMOChannelSettings: Loading preset [%s | %s]", qPrintable(preset->getGroup()), qPrintable(preset->getDescription())); qDebug("DeviceUISet::loadMIMOChannelSettings: Loading preset [%s | %s]",
qPrintable(preset->getGroup()), qPrintable(preset->getDescription()));
// Available channel plugins // Available channel plugins
PluginAPI::ChannelRegistrations *channelRegistrations = pluginAPI->getMIMOChannelRegistrations(); PluginAPI::ChannelRegistrations *channelRegistrations = pluginAPI->getMIMOChannelRegistrations();
// copy currently open channels and clear list // clear list
ChannelInstanceRegistrations openChannels = m_channelInstanceRegistrations; for(int i = 0; i < m_channelInstanceRegistrations.count(); i++)
m_channelInstanceRegistrations.clear();
for(int i = 0; i < openChannels.count(); i++)
{ {
qDebug("DeviceUISet::loadMIMOChannelSettings: destroying old channel [%s]", qPrintable(openChannels[i].m_channelName)); qDebug("DeviceUISet::loadMIMOChannelSettings: destroying old channel [%s]",
openChannels[i].m_gui->destroy(); // FIXME: stop channel before qPrintable(m_channelInstanceRegistrations[i].m_channelURI));
m_channelInstanceRegistrations[i].m_gui->destroy(); // FIXME: stop channel before
m_channelInstanceRegistrations[i].m_channelAPI->destroy();
} }
m_channelInstanceRegistrations.clear();
qDebug("DeviceUISet::loadMIMOChannelSettings: %d channel(s) in preset", preset->getChannelCount()); qDebug("DeviceUISet::loadMIMOChannelSettings: %d channel(s) in preset", preset->getChannelCount());
for (int i = 0; i < preset->getChannelCount(); i++) for (int i = 0; i < preset->getChannelCount(); i++)
@ -359,6 +363,13 @@ void DeviceUISet::loadMIMOChannelSettings(const Preset *preset, PluginAPI *plugi
mimoChannelGUI = (*channelRegistrations)[i].m_plugin->createMIMOChannelGUI(this, mimoChannel); mimoChannelGUI = (*channelRegistrations)[i].m_plugin->createMIMOChannelGUI(this, mimoChannel);
(*channelRegistrations)[i].m_plugin->createMIMOChannel(m_deviceAPI, &mimoChannel, &channelAPI); (*channelRegistrations)[i].m_plugin->createMIMOChannel(m_deviceAPI, &mimoChannel, &channelAPI);
registerChannelInstance(channelAPI->getURI(), channelAPI, mimoChannelGUI); registerChannelInstance(channelAPI->getURI(), channelAPI, mimoChannelGUI);
QObject::connect(
mimoChannelGUI,
&ChannelGUI::closing,
this,
[=](){ this->handleChannelGUIClosing(mimoChannelGUI); },
Qt::QueuedConnection
);
break; break;
} }
} }
@ -384,8 +395,8 @@ void DeviceUISet::saveMIMOChannelSettings(Preset *preset)
for(int i = 0; i < m_channelInstanceRegistrations.count(); i++) for(int i = 0; i < m_channelInstanceRegistrations.count(); i++)
{ {
qDebug("DeviceUISet::saveMIMOChannelSettings: saving channel [%s]", qPrintable(m_channelInstanceRegistrations[i].m_channelName)); qDebug("DeviceUISet::saveMIMOChannelSettings: saving channel [%s]", qPrintable(m_channelInstanceRegistrations[i].m_channelURI));
preset->addChannel(m_channelInstanceRegistrations[i].m_channelName, m_channelInstanceRegistrations[i].m_gui->serialize()); preset->addChannel(m_channelInstanceRegistrations[i].m_channelURI, m_channelInstanceRegistrations[i].m_gui->serialize());
} }
} }
else else
@ -414,3 +425,15 @@ bool DeviceUISet::ChannelInstanceRegistration::operator<(const ChannelInstanceRe
} }
} }
void DeviceUISet::handleChannelGUIClosing(ChannelGUI* channelGUI)
{
for (ChannelInstanceRegistrations::iterator it = m_channelInstanceRegistrations.begin(); it != m_channelInstanceRegistrations.end(); ++it)
{
if (it->m_gui == channelGUI)
{
it->m_channelAPI->destroy();
m_channelInstanceRegistrations.erase(it);
break;
}
}
}

View File

@ -18,6 +18,7 @@
#ifndef SDRGUI_DEVICE_DEVICEUISET_H_ #ifndef SDRGUI_DEVICE_DEVICEUISET_H_
#define SDRGUI_DEVICE_DEVICEUISET_H_ #define SDRGUI_DEVICE_DEVICEUISET_H_
#include <QObject>
#include <QTimer> #include <QTimer>
#include <QByteArray> #include <QByteArray>
@ -38,8 +39,9 @@ class ChannelAPI;
class ChannelGUI; class ChannelGUI;
class Preset; class Preset;
class SDRGUI_API DeviceUISet class SDRGUI_API DeviceUISet : public QObject
{ {
Q_OBJECT
public: public:
SpectrumVis *m_spectrumVis; SpectrumVis *m_spectrumVis;
GLSpectrum *m_spectrum; GLSpectrum *m_spectrum;
@ -72,9 +74,6 @@ public:
void registerRxChannelInstance(const QString& channelName, ChannelAPI *channelAPI, ChannelGUI* channelGUI); void registerRxChannelInstance(const QString& channelName, ChannelAPI *channelAPI, ChannelGUI* channelGUI);
void registerTxChannelInstance(const QString& channelName, ChannelAPI *channelAPI, ChannelGUI* channelGUI); void registerTxChannelInstance(const QString& channelName, ChannelAPI *channelAPI, ChannelGUI* channelGUI);
void registerChannelInstance(const QString& channelName, ChannelAPI *channelAPI, ChannelGUI* channelGUI); void registerChannelInstance(const QString& channelName, ChannelAPI *channelAPI, ChannelGUI* channelGUI);
void removeRxChannelInstance(ChannelGUI* channelGUI);
void removeTxChannelInstance(ChannelGUI* channelGUI);
void removeChannelInstance(ChannelGUI* channelGUI);
// These are the number of channel types available for selection // These are the number of channel types available for selection
void setNumberOfAvailableRxChannels(int number) { m_nbAvailableRxChannels = number; } void setNumberOfAvailableRxChannels(int number) { m_nbAvailableRxChannels = number; }
@ -87,22 +86,22 @@ public:
private: private:
struct ChannelInstanceRegistration struct ChannelInstanceRegistration
{ {
QString m_channelName; QString m_channelURI;
ChannelAPI *m_channelAPI; ChannelAPI *m_channelAPI;
ChannelGUI* m_gui; ChannelGUI* m_gui;
int m_channelType; int m_channelType;
ChannelInstanceRegistration() : ChannelInstanceRegistration() :
m_channelName(), m_channelURI(),
m_channelAPI(nullptr),
m_gui(nullptr), m_gui(nullptr),
m_channelAPI(nullptr),
m_channelType(0) m_channelType(0)
{ } { }
ChannelInstanceRegistration(const QString& channelName, ChannelAPI *channelAPI, ChannelGUI* channelGUI, int channelType) : ChannelInstanceRegistration(const QString& channelName, ChannelAPI *channelAPI, ChannelGUI* channelGUI, int channelType) :
m_channelName(channelName), m_channelURI(channelName),
m_channelAPI(channelAPI),
m_gui(channelGUI), m_gui(channelGUI),
m_channelAPI(channelAPI),
m_channelType(channelType) m_channelType(channelType)
{ } { }
@ -118,6 +117,9 @@ private:
int m_nbAvailableRxChannels; //!< Number of Rx channels available for selection int m_nbAvailableRxChannels; //!< Number of Rx channels available for selection
int m_nbAvailableTxChannels; //!< Number of Tx channels available for selection int m_nbAvailableTxChannels; //!< Number of Tx channels available for selection
int m_nbAvailableMIMOChannels; //!< Number of MIMO channels available for selection int m_nbAvailableMIMOChannels; //!< Number of MIMO channels available for selection
private slots:
void handleChannelGUIClosing(ChannelGUI* channelGUI);
}; };

View File

@ -49,23 +49,11 @@ void FeatureUISet::registerFeatureInstance(const QString& featureURI, FeatureGUI
featureGUI, featureGUI,
&FeatureGUI::closing, &FeatureGUI::closing,
this, this,
[=](){ this->handleClosingFeatureGUI(featureGUI, feature); }, [=](){ this->handleClosingFeatureGUI(featureGUI); },
Qt::QueuedConnection Qt::QueuedConnection
); );
} }
void FeatureUISet::removeFeatureInstance(FeatureGUI* featureGUI)
{
for (FeatureInstanceRegistrations::iterator it = m_featureInstanceRegistrations.begin(); it != m_featureInstanceRegistrations.end(); ++it)
{
if (it->m_gui == featureGUI)
{
m_featureInstanceRegistrations.erase(it);
break;
}
}
}
// sort by name // sort by name
bool FeatureUISet::FeatureInstanceRegistration::operator<(const FeatureInstanceRegistration& other) const bool FeatureUISet::FeatureInstanceRegistration::operator<(const FeatureInstanceRegistration& other) const
{ {
@ -179,8 +167,15 @@ void FeatureUISet::saveFeatureSetSettings(FeatureSetPreset *preset)
} }
void FeatureUISet::handleClosingFeatureGUI(FeatureGUI *featureGUI, Feature *feature) void FeatureUISet::handleClosingFeatureGUI(FeatureGUI *featureGUI)
{ {
removeFeatureInstance(featureGUI); for (FeatureInstanceRegistrations::iterator it = m_featureInstanceRegistrations.begin(); it != m_featureInstanceRegistrations.end(); ++it)
feature->destroy(); {
if (it->m_gui == featureGUI)
{
it->m_feature->destroy();
m_featureInstanceRegistrations.erase(it);
break;
}
}
} }

View File

@ -42,7 +42,6 @@ public:
void addRollupWidget(QWidget *widget); //!< Add feature rollup widget to feature window void addRollupWidget(QWidget *widget); //!< Add feature rollup widget to feature window
int getNumberOfFeatures() const { return m_featureInstanceRegistrations.size(); } int getNumberOfFeatures() const { return m_featureInstanceRegistrations.size(); }
void registerFeatureInstance(const QString& featureURI, FeatureGUI* featureGUI, Feature *feature); void registerFeatureInstance(const QString& featureURI, FeatureGUI* featureGUI, Feature *feature);
void removeFeatureInstance(FeatureGUI* featureGUI);
void deleteFeature(int featureIndex); void deleteFeature(int featureIndex);
const Feature *getFeatureAt(int featureIndex) const; const Feature *getFeatureAt(int featureIndex) const;
Feature *getFeatureAt(int featureIndex); Feature *getFeatureAt(int featureIndex);
@ -81,7 +80,7 @@ private:
void freeFeatures(); void freeFeatures();
private slots: private slots:
void handleClosingFeatureGUI(FeatureGUI *featureGUI, Feature *feature); void handleClosingFeatureGUI(FeatureGUI *featureGUI);
}; };
#endif // SDRGUI_FEATURE_FEATUREUISET_H_ #endif // SDRGUI_FEATURE_FEATUREUISET_H_

View File

@ -1924,13 +1924,6 @@ void MainWindow::channelAddClicked(int channelIndex)
pluginInterface->createRxChannel(deviceUI->m_deviceAPI, &rxChannel, &channelAPI); pluginInterface->createRxChannel(deviceUI->m_deviceAPI, &rxChannel, &channelAPI);
ChannelGUI *gui = pluginInterface->createRxChannelGUI(deviceUI, rxChannel); ChannelGUI *gui = pluginInterface->createRxChannelGUI(deviceUI, rxChannel);
deviceUI->registerRxChannelInstance(channelAPI->getURI(), channelAPI, gui); deviceUI->registerRxChannelInstance(channelAPI->getURI(), channelAPI, gui);
QObject::connect(
gui,
&ChannelGUI::closing,
this,
[=](){ this->handleClosingRxChannelGUI(deviceUI, gui); },
Qt::QueuedConnection
);
} }
else if (deviceUI->m_deviceSinkEngine) // sink device => Tx channels else if (deviceUI->m_deviceSinkEngine) // sink device => Tx channels
{ {
@ -1941,13 +1934,6 @@ void MainWindow::channelAddClicked(int channelIndex)
pluginInterface->createTxChannel(deviceUI->m_deviceAPI, &txChannel, &channelAPI); pluginInterface->createTxChannel(deviceUI->m_deviceAPI, &txChannel, &channelAPI);
ChannelGUI *gui = pluginInterface->createTxChannelGUI(deviceUI, txChannel); ChannelGUI *gui = pluginInterface->createTxChannelGUI(deviceUI, txChannel);
deviceUI->registerTxChannelInstance(channelAPI->getURI(), channelAPI, gui); deviceUI->registerTxChannelInstance(channelAPI->getURI(), channelAPI, gui);
QObject::connect(
gui,
&ChannelGUI::closing,
this,
[=](){ this->handleClosingTxChannelGUI(deviceUI, gui); },
Qt::QueuedConnection
);
} }
else if (deviceUI->m_deviceMIMOEngine) // MIMO device => all possible channels. Depends on index range else if (deviceUI->m_deviceMIMOEngine) // MIMO device => all possible channels. Depends on index range
{ {
@ -1965,13 +1951,6 @@ void MainWindow::channelAddClicked(int channelIndex)
pluginInterface->createRxChannel(deviceUI->m_deviceAPI, &rxChannel, &channelAPI); pluginInterface->createRxChannel(deviceUI->m_deviceAPI, &rxChannel, &channelAPI);
ChannelGUI *gui = pluginInterface->createRxChannelGUI(deviceUI, rxChannel); ChannelGUI *gui = pluginInterface->createRxChannelGUI(deviceUI, rxChannel);
deviceUI->registerRxChannelInstance(channelAPI->getURI(), channelAPI, gui); deviceUI->registerRxChannelInstance(channelAPI->getURI(), channelAPI, gui);
QObject::connect(
gui,
&ChannelGUI::closing,
this,
[=](){ this->handleClosingRxChannelGUI(deviceUI, gui); },
Qt::QueuedConnection
);
} }
else if (channelIndex < nbRxChannels + nbTxChannels) else if (channelIndex < nbRxChannels + nbTxChannels)
{ {
@ -1982,13 +1961,6 @@ void MainWindow::channelAddClicked(int channelIndex)
pluginInterface->createTxChannel(deviceUI->m_deviceAPI, &txChannel, &channelAPI); pluginInterface->createTxChannel(deviceUI->m_deviceAPI, &txChannel, &channelAPI);
ChannelGUI *gui = pluginInterface->createTxChannelGUI(deviceUI, txChannel); ChannelGUI *gui = pluginInterface->createTxChannelGUI(deviceUI, txChannel);
deviceUI->registerTxChannelInstance(channelAPI->getURI(), channelAPI, gui); deviceUI->registerTxChannelInstance(channelAPI->getURI(), channelAPI, gui);
QObject::connect(
gui,
&ChannelGUI::closing,
this,
[=](){ this->handleClosingTxChannelGUI(deviceUI, gui); },
Qt::QueuedConnection
);
} }
} }
} }
@ -2177,18 +2149,3 @@ void MainWindow::commandKeyPressed(Qt::Key key, Qt::KeyboardModifiers keyModifie
} }
} }
} }
void MainWindow::handleClosingRxChannelGUI(DeviceUISet *deviceUISet, ChannelGUI *gui)
{
deviceUISet->removeRxChannelInstance(gui);
}
void MainWindow::handleClosingTxChannelGUI(DeviceUISet *deviceUISet, ChannelGUI *gui)
{
deviceUISet->removeTxChannelInstance(gui);
}
void MainWindow::handleClosingMIMOChannelGUI(DeviceUISet *deviceUISet, ChannelGUI *gui)
{
deviceUISet->removeChannelInstance(gui);
}

View File

@ -533,9 +533,6 @@ private slots:
void tabInputViewIndexChanged(); void tabInputViewIndexChanged();
void tabChannelsIndexChanged(); void tabChannelsIndexChanged();
void commandKeyPressed(Qt::Key key, Qt::KeyboardModifiers keyModifiers, bool release); void commandKeyPressed(Qt::Key key, Qt::KeyboardModifiers keyModifiers, bool release);
void handleClosingRxChannelGUI(DeviceUISet *deviceUISet, ChannelGUI *gui);
void handleClosingTxChannelGUI(DeviceUISet *deviceUISet, ChannelGUI *gui);
void handleClosingMIMOChannelGUI(DeviceUISet *deviceUISet, ChannelGUI *gui);
}; };
#endif // INCLUDE_MAINWINDOW_H #endif // INCLUDE_MAINWINDOW_H