1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2025-06-25 05:25:27 -04:00

Delete Feature in FeatureUISet

This commit is contained in:
f4exb 2020-10-04 10:30:49 +02:00
parent b1c9a35dcb
commit e9a32528d7
4 changed files with 10 additions and 7 deletions

View File

@ -145,7 +145,6 @@ RigCtlServerGUI::RigCtlServerGUI(PluginAPI* pluginAPI, FeatureUISet *featureUISe
RigCtlServerGUI::~RigCtlServerGUI() RigCtlServerGUI::~RigCtlServerGUI()
{ {
delete m_rigCtlServer; // When the GUI closes it has to delete the demodulator because it can be done with (x)
delete ui; delete ui;
} }

View File

@ -160,7 +160,6 @@ SimplePTTGUI::SimplePTTGUI(PluginAPI* pluginAPI, FeatureUISet *featureUISet, Fea
SimplePTTGUI::~SimplePTTGUI() SimplePTTGUI::~SimplePTTGUI()
{ {
delete m_simplePTT; // When the GUI closes it has to delete the demodulator because it can be done with (x)
delete ui; delete ui;
} }

View File

@ -33,6 +33,7 @@ FeatureUISet::FeatureUISet(int tabIndex)
FeatureUISet::~FeatureUISet() FeatureUISet::~FeatureUISet()
{ {
freeFeatures();
delete m_featureWindow; delete m_featureWindow;
} }
@ -48,7 +49,7 @@ void FeatureUISet::registerFeatureInstance(const QString& featureURI, FeatureGUI
featureGUI, featureGUI,
&FeatureGUI::closing, &FeatureGUI::closing,
this, this,
[=](){ this->handleClosingFeatureGUI(featureGUI); }, [=](){ this->handleClosingFeatureGUI(featureGUI, feature); },
Qt::QueuedConnection Qt::QueuedConnection
); );
} }
@ -81,6 +82,7 @@ void FeatureUISet::freeFeatures()
{ {
qDebug("FeatureUISet::freeFeatures: destroying feature [%s]", qPrintable(m_featureInstanceRegistrations[i].m_featureURI)); qDebug("FeatureUISet::freeFeatures: destroying feature [%s]", qPrintable(m_featureInstanceRegistrations[i].m_featureURI));
m_featureInstanceRegistrations[i].m_gui->destroy(); m_featureInstanceRegistrations[i].m_gui->destroy();
m_featureInstanceRegistrations[i].m_feature->destroy();
} }
} }
@ -92,6 +94,7 @@ void FeatureUISet::deleteFeature(int featureIndex)
qPrintable(m_featureInstanceRegistrations[featureIndex].m_featureURI), qPrintable(m_featureInstanceRegistrations[featureIndex].m_featureURI),
featureIndex); featureIndex);
m_featureInstanceRegistrations[featureIndex].m_gui->destroy(); m_featureInstanceRegistrations[featureIndex].m_gui->destroy();
m_featureInstanceRegistrations[featureIndex].m_feature->destroy();
} }
} }
@ -128,6 +131,7 @@ void FeatureUISet::loadFeatureSetSettings(const FeatureSetPreset *preset, Plugin
{ {
qDebug("FeatureUISet::loadFeatureSetSettings: destroying old feature [%s]", qPrintable(openFeatures[i].m_featureURI)); qDebug("FeatureUISet::loadFeatureSetSettings: destroying old feature [%s]", qPrintable(openFeatures[i].m_featureURI));
openFeatures[i].m_gui->destroy(); openFeatures[i].m_gui->destroy();
openFeatures[i].m_feature->destroy();
} }
qDebug("FeatureUISet::loadFeatureSetSettings: %d feature(s) in preset", preset->getFeatureCount()); qDebug("FeatureUISet::loadFeatureSetSettings: %d feature(s) in preset", preset->getFeatureCount());
@ -175,8 +179,8 @@ void FeatureUISet::saveFeatureSetSettings(FeatureSetPreset *preset)
} }
void FeatureUISet::handleClosingFeatureGUI(FeatureGUI *featureGUI) void FeatureUISet::handleClosingFeatureGUI(FeatureGUI *featureGUI, Feature *feature)
{ {
qDebug("FeatureUISet::handleClosingFeatureGUI");
removeFeatureInstance(featureGUI); removeFeatureInstance(featureGUI);
feature->destroy();
} }

View File

@ -43,7 +43,6 @@ public:
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 removeFeatureInstance(FeatureGUI* featureGUI);
void freeFeatures();
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);
@ -79,8 +78,10 @@ private:
FeatureInstanceRegistrations m_featureInstanceRegistrations; FeatureInstanceRegistrations m_featureInstanceRegistrations;
int m_featureTabIndex; int m_featureTabIndex;
void freeFeatures();
private slots: private slots:
void handleClosingFeatureGUI(FeatureGUI *featureGUI); void handleClosingFeatureGUI(FeatureGUI *featureGUI, Feature *feature);
}; };
#endif // SDRGUI_FEATURE_FEATUREUISET_H_ #endif // SDRGUI_FEATURE_FEATUREUISET_H_