Merge pull request #975 from projectkk2glider/companion_memory_leaks
Companion memory leaks fixed
This commit is contained in:
@@ -123,5 +123,7 @@ int main(int argc, char *argv[])
|
|||||||
delete splash;
|
delete splash;
|
||||||
delete mainWin;
|
delete mainWin;
|
||||||
|
|
||||||
|
UnregisterFirmwares();
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
#include "firmwares/th9x/th9xinterface.h"
|
#include "firmwares/th9x/th9xinterface.h"
|
||||||
#include "firmwares/gruvin9x/gruvin9xinterface.h"
|
#include "firmwares/gruvin9x/gruvin9xinterface.h"
|
||||||
#include "firmwares/opentx/opentxinterface.h"
|
#include "firmwares/opentx/opentxinterface.h"
|
||||||
|
#include "firmwares/opentx/opentxeeprom.h"
|
||||||
#include "firmwares/ersky9x/ersky9xinterface.h"
|
#include "firmwares/ersky9x/ersky9xinterface.h"
|
||||||
#include "appdata.h"
|
#include "appdata.h"
|
||||||
#include "helpers.h"
|
#include "helpers.h"
|
||||||
@@ -1199,6 +1200,15 @@ void RegisterEepromInterfaces()
|
|||||||
eepromInterfaces.push_back(new Er9xInterface());
|
eepromInterfaces.push_back(new Er9xInterface());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UnregisterEepromInterfaces()
|
||||||
|
{
|
||||||
|
foreach(EEPROMInterface * intf, eepromInterfaces) {
|
||||||
|
qDebug() << "UnregisterEepromInterfaces(): deleting " << QString::number( reinterpret_cast<uint64_t>(intf), 16 );
|
||||||
|
delete intf;
|
||||||
|
}
|
||||||
|
OpenTxEepromCleanup();
|
||||||
|
}
|
||||||
|
|
||||||
QList<FirmwareInfo *> firmwares;
|
QList<FirmwareInfo *> firmwares;
|
||||||
FirmwareVariant default_firmware_variant;
|
FirmwareVariant default_firmware_variant;
|
||||||
FirmwareVariant current_firmware_variant;
|
FirmwareVariant current_firmware_variant;
|
||||||
@@ -1211,6 +1221,13 @@ void RegisterFirmwares()
|
|||||||
RegisterEepromInterfaces();
|
RegisterEepromInterfaces();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UnregisterFirmwares()
|
||||||
|
{
|
||||||
|
UnregisterEepromInterfaces();
|
||||||
|
UnregisterOpen9xFirmwares();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool LoadEeprom(RadioData &radioData, const uint8_t *eeprom, const int size)
|
bool LoadEeprom(RadioData &radioData, const uint8_t *eeprom, const int size)
|
||||||
{
|
{
|
||||||
foreach(EEPROMInterface *eepromInterface, eepromInterfaces) {
|
foreach(EEPROMInterface *eepromInterface, eepromInterfaces) {
|
||||||
|
|||||||
@@ -1244,6 +1244,7 @@ inline void applyStickModeToModel(ModelData &model, unsigned int mode)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void RegisterFirmwares();
|
void RegisterFirmwares();
|
||||||
|
void UnregisterFirmwares();
|
||||||
|
|
||||||
bool LoadBackup(RadioData &radioData, uint8_t *eeprom, int esize, int index);
|
bool LoadBackup(RadioData &radioData, uint8_t *eeprom, int esize, int index);
|
||||||
bool LoadEeprom(RadioData &radioData, const uint8_t *eeprom, int size);
|
bool LoadEeprom(RadioData &radioData, const uint8_t *eeprom, int size);
|
||||||
@@ -1268,6 +1269,7 @@ class FirmwareInfo {
|
|||||||
|
|
||||||
virtual ~FirmwareInfo()
|
virtual ~FirmwareInfo()
|
||||||
{
|
{
|
||||||
|
delete eepromInterface;
|
||||||
}
|
}
|
||||||
|
|
||||||
FirmwareInfo(const QString & id, const QString & name, EEPROMInterface * eepromInterface, const QString & url = QString(), const QString & stamp = QString(), const QString & rnurl = QString(), bool voice = false):
|
FirmwareInfo(const QString & id, const QString & name, EEPROMInterface * eepromInterface, const QString & url = QString(), const QString & stamp = QString(), const QString & rnurl = QString(), bool voice = false):
|
||||||
|
|||||||
@@ -129,12 +129,12 @@ class SwitchesConversionTable: public ConversionTable {
|
|||||||
SwitchesConversionTable * table;
|
SwitchesConversionTable * table;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static std::list<Cache> internalCache;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
static SwitchesConversionTable * getInstance(BoardEnum board, unsigned int version, unsigned long flags=0)
|
static SwitchesConversionTable * getInstance(BoardEnum board, unsigned int version, unsigned long flags=0)
|
||||||
{
|
{
|
||||||
static std::list<Cache> internalCache;
|
|
||||||
|
|
||||||
for (std::list<Cache>::iterator it=internalCache.begin(); it!=internalCache.end(); it++) {
|
for (std::list<Cache>::iterator it=internalCache.begin(); it!=internalCache.end(); it++) {
|
||||||
Cache element = *it;
|
Cache element = *it;
|
||||||
if (element.board == board && element.version == version && element.flags == flags)
|
if (element.board == board && element.version == version && element.flags == flags)
|
||||||
@@ -145,8 +145,18 @@ class SwitchesConversionTable: public ConversionTable {
|
|||||||
internalCache.push_back(element);
|
internalCache.push_back(element);
|
||||||
return element.table;
|
return element.table;
|
||||||
}
|
}
|
||||||
|
static void Cleanup()
|
||||||
|
{
|
||||||
|
for (std::list<Cache>::iterator it=internalCache.begin(); it!=internalCache.end(); it++) {
|
||||||
|
Cache element = *it;
|
||||||
|
delete element.table;
|
||||||
|
}
|
||||||
|
internalCache.clear();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
std::list<SwitchesConversionTable::Cache> SwitchesConversionTable::internalCache;
|
||||||
|
|
||||||
#define FLAG_NONONE 0x01
|
#define FLAG_NONONE 0x01
|
||||||
#define FLAG_NOSWITCHES 0x02
|
#define FLAG_NOSWITCHES 0x02
|
||||||
#define FLAG_NOTELEMETRY 0x04
|
#define FLAG_NOTELEMETRY 0x04
|
||||||
@@ -281,13 +291,12 @@ class SourcesConversionTable: public ConversionTable {
|
|||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
SourcesConversionTable * table;
|
SourcesConversionTable * table;
|
||||||
};
|
};
|
||||||
|
static std::list<Cache> internalCache;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
static SourcesConversionTable * getInstance(BoardEnum board, unsigned int version, unsigned int variant, unsigned long flags=0)
|
static SourcesConversionTable * getInstance(BoardEnum board, unsigned int version, unsigned int variant, unsigned long flags=0)
|
||||||
{
|
{
|
||||||
static std::list<Cache> internalCache;
|
|
||||||
|
|
||||||
for (std::list<Cache>::iterator it=internalCache.begin(); it!=internalCache.end(); it++) {
|
for (std::list<Cache>::iterator it=internalCache.begin(); it!=internalCache.end(); it++) {
|
||||||
Cache element = *it;
|
Cache element = *it;
|
||||||
if (element.board == board && element.version == version && element.variant == variant && element.flags == flags)
|
if (element.board == board && element.version == version && element.variant == variant && element.flags == flags)
|
||||||
@@ -298,8 +307,24 @@ class SourcesConversionTable: public ConversionTable {
|
|||||||
internalCache.push_back(element);
|
internalCache.push_back(element);
|
||||||
return element.table;
|
return element.table;
|
||||||
}
|
}
|
||||||
|
static void Cleanup()
|
||||||
|
{
|
||||||
|
for (std::list<Cache>::iterator it=internalCache.begin(); it!=internalCache.end(); it++) {
|
||||||
|
Cache element = *it;
|
||||||
|
delete element.table;
|
||||||
|
}
|
||||||
|
internalCache.clear();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
std::list<SourcesConversionTable::Cache> SourcesConversionTable::internalCache;
|
||||||
|
|
||||||
|
void OpenTxEepromCleanup(void)
|
||||||
|
{
|
||||||
|
SourcesConversionTable::Cleanup();
|
||||||
|
SwitchesConversionTable::Cleanup();
|
||||||
|
}
|
||||||
|
|
||||||
ThrottleSourceConversionTable::ThrottleSourceConversionTable(BoardEnum board, unsigned int version)
|
ThrottleSourceConversionTable::ThrottleSourceConversionTable(BoardEnum board, unsigned int version)
|
||||||
{
|
{
|
||||||
int val=0;
|
int val=0;
|
||||||
@@ -1444,6 +1469,10 @@ class LogicalSwitchField: public TransformedField {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
~LogicalSwitchField()
|
||||||
|
{
|
||||||
|
delete andswitchesConversionTable;
|
||||||
|
}
|
||||||
virtual void beforeExport()
|
virtual void beforeExport()
|
||||||
{
|
{
|
||||||
if (csw.func == LS_FN_TIMER) {
|
if (csw.func == LS_FN_TIMER) {
|
||||||
|
|||||||
@@ -144,4 +144,5 @@ class OpenTxModelData: public TransformedField {
|
|||||||
ChannelsConversionTable channelsConversionTable;
|
ChannelsConversionTable channelsConversionTable;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void OpenTxEepromCleanup(void);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1230,3 +1230,11 @@ void RegisterOpen9xFirmwares()
|
|||||||
firmwares.push_back(open9x);
|
firmwares.push_back(open9x);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UnregisterOpen9xFirmwares()
|
||||||
|
{
|
||||||
|
foreach (FirmwareInfo * f, firmwares) {
|
||||||
|
qDebug() << "UnregisterOpen9xFirmwares(): deleting " << QString::number(reinterpret_cast<uint64_t>(f), 16 );
|
||||||
|
delete f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -164,5 +164,6 @@ class Open9xFirmware: public FirmwareInfo {
|
|||||||
};
|
};
|
||||||
|
|
||||||
void RegisterOpen9xFirmwares();
|
void RegisterOpen9xFirmwares();
|
||||||
|
void UnregisterOpen9xFirmwares();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
#include "appdata.h"
|
#include "appdata.h"
|
||||||
#include "helpers.h"
|
#include "helpers.h"
|
||||||
#include "simulatordialog.h"
|
#include "simulatordialog.h"
|
||||||
|
#include "simulatorinterface.h"
|
||||||
#include "flashinterface.h"
|
#include "flashinterface.h"
|
||||||
|
|
||||||
const QColor colors[C9X_MAX_CURVES] = {
|
const QColor colors[C9X_MAX_CURVES] = {
|
||||||
@@ -905,7 +906,9 @@ CompanionIcon::CompanionIcon(QString baseimage)
|
|||||||
|
|
||||||
void startSimulation(QWidget * parent, RadioData & radioData, int modelIdx)
|
void startSimulation(QWidget * parent, RadioData & radioData, int modelIdx)
|
||||||
{
|
{
|
||||||
if (GetEepromInterface()->getSimulator()) {
|
SimulatorInterface * si = GetEepromInterface()->getSimulator();
|
||||||
|
if (si) {
|
||||||
|
delete si;
|
||||||
RadioData * simuData = new RadioData(radioData);
|
RadioData * simuData = new RadioData(radioData);
|
||||||
unsigned int flags = 0;
|
unsigned int flags = 0;
|
||||||
if (modelIdx >= 0) {
|
if (modelIdx >= 0) {
|
||||||
|
|||||||
@@ -87,7 +87,7 @@
|
|||||||
MainWindow::MainWindow():
|
MainWindow::MainWindow():
|
||||||
downloadDialog_forWait(NULL)
|
downloadDialog_forWait(NULL)
|
||||||
{
|
{
|
||||||
mdiArea = new QMdiArea;
|
mdiArea = new QMdiArea(this);
|
||||||
mdiArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
|
mdiArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
|
||||||
mdiArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
|
mdiArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
|
||||||
setCentralWidget(mdiArea);
|
setCentralWidget(mdiArea);
|
||||||
@@ -1681,10 +1681,10 @@ void MainWindow::createActions()
|
|||||||
void MainWindow::createMenus()
|
void MainWindow::createMenus()
|
||||||
|
|
||||||
{
|
{
|
||||||
QMenu *recentFileMenu=new QMenu(tr("Recent Files"));
|
QMenu *recentFileMenu=new QMenu(tr("Recent Files"), this);
|
||||||
QMenu *languageMenu=new QMenu(tr("Set Menu Language"));
|
QMenu *languageMenu=new QMenu(tr("Set Menu Language"), this);
|
||||||
QMenu *themeMenu=new QMenu(tr("Set Icon Theme"));
|
QMenu *themeMenu=new QMenu(tr("Set Icon Theme"), this);
|
||||||
QMenu *iconThemeSizeMenu=new QMenu(tr("Set Icon Size"));
|
QMenu *iconThemeSizeMenu=new QMenu(tr("Set Icon Size"), this);
|
||||||
|
|
||||||
fileMenu = menuBar()->addMenu(tr("File"));
|
fileMenu = menuBar()->addMenu(tr("File"));
|
||||||
fileMenu->addAction(newAct);
|
fileMenu->addAction(newAct);
|
||||||
@@ -1783,7 +1783,7 @@ QMenu *MainWindow::createRecentFileMenu()
|
|||||||
|
|
||||||
QMenu *MainWindow::createProfilesMenu()
|
QMenu *MainWindow::createProfilesMenu()
|
||||||
{
|
{
|
||||||
QMenu *profilesMenu=new QMenu(tr("Radio Profile"));
|
QMenu *profilesMenu=new QMenu(tr("Radio Profile"), this);
|
||||||
int i;
|
int i;
|
||||||
for ( i = 0; i < MAX_PROFILES; ++i) {
|
for ( i = 0; i < MAX_PROFILES; ++i) {
|
||||||
profilesMenu->addAction(profileActs[i]);
|
profilesMenu->addAction(profileActs[i]);
|
||||||
|
|||||||
@@ -82,6 +82,11 @@ MdiChild::MdiChild():
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MdiChild::~MdiChild()
|
||||||
|
{
|
||||||
|
delete ui;
|
||||||
|
}
|
||||||
|
|
||||||
void MdiChild::qSleep(int ms)
|
void MdiChild::qSleep(int ms)
|
||||||
{
|
{
|
||||||
if (ms<0)
|
if (ms<0)
|
||||||
|
|||||||
@@ -61,6 +61,7 @@ class MdiChild : public QWidget
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
MdiChild();
|
MdiChild();
|
||||||
|
~MdiChild();
|
||||||
|
|
||||||
void newFile();
|
void newFile();
|
||||||
bool loadFile(const QString &fileName, bool resetCurrentFile=true);
|
bool loadFile(const QString &fileName, bool resetCurrentFile=true);
|
||||||
|
|||||||
@@ -142,6 +142,7 @@ SimulatorDialogTaranis::~SimulatorDialogTaranis()
|
|||||||
SimulatorDialog::~SimulatorDialog()
|
SimulatorDialog::~SimulatorDialog()
|
||||||
{
|
{
|
||||||
delete timer;
|
delete timer;
|
||||||
|
delete simulator;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SimulatorDialog::closeEvent (QCloseEvent *)
|
void SimulatorDialog::closeEvent (QCloseEvent *)
|
||||||
|
|||||||
@@ -48,6 +48,8 @@ class SimulatorInterface {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
virtual ~SimulatorInterface() {};
|
||||||
|
|
||||||
virtual void start(QByteArray & eeprom, bool tests=true) = 0;
|
virtual void start(QByteArray & eeprom, bool tests=true) = 0;
|
||||||
|
|
||||||
virtual void start(const char * filename, bool tests=true) = 0;
|
virtual void start(const char * filename, bool tests=true) = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user