[simulation] Fix some potential crashes & 26 memory leaks, improve LCD redraws. (#4634)
* [simulation] Hardening: Fix some potential crashes & 26 memory leaks, improve LCD performance. * [simpgmspace] Init trims; Make sure `REa` is really defined (to match board files). * [simpgmspace][opentxsimulator] Verify current running state before start/stop; Move rotary enc. init. * [simpgmspace][LcdWidget] Improve performance by moving LCD content change check to lcdRefresh() & limiting LcdWidget refresh time to 60 fps max. * [simueeprom] Ensure thread could be started, set default running state to false. * [simufatfs] Fix paths report trace. * [eepromimportexport] Fix memory leaks resulting from import debugging scheme being used. * [customdebug] Introduce new scheme for custom debug output in compliance with Qt recommendations (see docs for QLoggingCategory). * [opentxeeprom] Fix extra conversion table cache elements being created and also not properly deleted (and hence leaking). * [opentxinterface] Unregister EEpromInterfaces in unregisterOpenTxFirmwares(); * [storage] Unregister storage factories on exit (fixes leak); create virtual StorageFormat/StorageFactory destructors (prevents warnings). * [helpers] GVarGroup now emits own signal, no need to pass ModelPanel pointer (removes dependency on modeledit.h) * [DebugOutput] Clear simulator trace hook before exiting (prevent possible issues); Fix leak and possible bad QString allocations when reading from buffer; Fix leak with combo box event filter. * [TelemetrySimulator] Fix leak by deleting LogPlaybackController object on exit; Only set up data fields once; convert timers to static. * [build] Consolidate all Companion/Simulator shared items in `common` library to reduce build time/etc (node & edge still remain awkward). * [simulatorwidget] Delete removed spacer object (previously-forgotten "26th" leak). * [DebugOutput] Fix stray trailing characters issue with new text buffer allocation (from previous commit); Increase maximum buffer sizes to better accommodate slower systems. * Cosmetics.
This commit is contained in:
committed by
Bertrand Songis
parent
52e65179a8
commit
4aa0c1bbe4
@@ -31,12 +31,12 @@ TelemetrySimulator::TelemetrySimulator(QWidget * parent, SimulatorInterface * si
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
timer = new QTimer(this);
|
||||
timer->setInterval(10);
|
||||
connect(timer, SIGNAL(timeout()), this, SLOT(onTimerEvent()));
|
||||
setupDataFields();
|
||||
|
||||
logTimer = new QTimer(this);
|
||||
connect(logTimer, SIGNAL(timeout()), this, SLOT(onLogTimerEvent()));
|
||||
timer.setInterval(10);
|
||||
connect(&timer, &QTimer::timeout, this, &TelemetrySimulator::generateTelemetryFrame);
|
||||
|
||||
connect(&logTimer, &QTimer::timeout, this, &TelemetrySimulator::onLogTimerEvent);
|
||||
|
||||
connect(ui->Simulate, SIGNAL(toggled(bool)), this, SLOT(onSimulateToggled(bool)));
|
||||
connect(ui->loadLogFile, SIGNAL(released()), this, SLOT(onLoadLogFile()));
|
||||
@@ -64,33 +64,27 @@ TelemetrySimulator::TelemetrySimulator(QWidget * parent, SimulatorInterface * si
|
||||
|
||||
TelemetrySimulator::~TelemetrySimulator()
|
||||
{
|
||||
timer->stop();
|
||||
logTimer->stop();
|
||||
timer.stop();
|
||||
logTimer.stop();
|
||||
delete logPlayback;
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void TelemetrySimulator::onSimulateToggled(bool isChecked)
|
||||
{
|
||||
if (isChecked) {
|
||||
timer->start();
|
||||
timer.start();
|
||||
}
|
||||
else {
|
||||
timer->stop();
|
||||
timer.stop();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void TelemetrySimulator::onLogTimerEvent()
|
||||
{
|
||||
logPlayback->stepForward(false);
|
||||
}
|
||||
|
||||
|
||||
void TelemetrySimulator::onTimerEvent()
|
||||
{
|
||||
generateTelemetryFrame();
|
||||
}
|
||||
|
||||
void TelemetrySimulator::onLoadLogFile()
|
||||
{
|
||||
onStop(); // in case we are in playback mode
|
||||
@@ -100,7 +94,7 @@ void TelemetrySimulator::onLoadLogFile()
|
||||
void TelemetrySimulator::onPlay()
|
||||
{
|
||||
if (logPlayback->isReady()) {
|
||||
logTimer->start(logPlayback->logFrequency * 1000 / SPEEDS[ui->replayRate->value()]);
|
||||
logTimer.start(logPlayback->logFrequency * 1000 / SPEEDS[ui->replayRate->value()]);
|
||||
logPlayback->play();
|
||||
}
|
||||
}
|
||||
@@ -108,7 +102,7 @@ void TelemetrySimulator::onPlay()
|
||||
void TelemetrySimulator::onRewind()
|
||||
{
|
||||
if (logPlayback->isReady()) {
|
||||
logTimer->stop();
|
||||
logTimer.stop();
|
||||
logPlayback->rewind();
|
||||
}
|
||||
}
|
||||
@@ -116,7 +110,7 @@ void TelemetrySimulator::onRewind()
|
||||
void TelemetrySimulator::onStepForward()
|
||||
{
|
||||
if (logPlayback->isReady()) {
|
||||
logTimer->stop();
|
||||
logTimer.stop();
|
||||
logPlayback->stepForward(true);
|
||||
}
|
||||
}
|
||||
@@ -124,7 +118,7 @@ void TelemetrySimulator::onStepForward()
|
||||
void TelemetrySimulator::onStepBack()
|
||||
{
|
||||
if (logPlayback->isReady()) {
|
||||
logTimer->stop();
|
||||
logTimer.stop();
|
||||
logPlayback->stepBack();
|
||||
}
|
||||
}
|
||||
@@ -132,7 +126,7 @@ void TelemetrySimulator::onStepBack()
|
||||
void TelemetrySimulator::onStop()
|
||||
{
|
||||
if (logPlayback->isReady()) {
|
||||
logTimer->stop();
|
||||
logTimer.stop();
|
||||
logPlayback->stop();
|
||||
}
|
||||
}
|
||||
@@ -147,21 +141,21 @@ void TelemetrySimulator::onPositionIndicatorChanged(int value)
|
||||
|
||||
void TelemetrySimulator::onReplayRateChanged(int value)
|
||||
{
|
||||
if (logTimer->isActive()) {
|
||||
logTimer->setInterval(logPlayback->logFrequency * 1000 / SPEEDS[ui->replayRate->value()]);
|
||||
if (logTimer.isActive()) {
|
||||
logTimer.setInterval(logPlayback->logFrequency * 1000 / SPEEDS[ui->replayRate->value()]);
|
||||
}
|
||||
}
|
||||
|
||||
void TelemetrySimulator::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
timer->stop();
|
||||
logTimer->stop();
|
||||
timer.stop();
|
||||
logTimer.stop();
|
||||
event->accept();
|
||||
}
|
||||
|
||||
#define SET_INSTANCE(control, id, def) ui->control->setText(QString::number(simulator->getSensorInstance(id, ((def) & 0x1F) + 1)))
|
||||
|
||||
void TelemetrySimulator::showEvent(QShowEvent *event)
|
||||
void TelemetrySimulator::setupDataFields()
|
||||
{
|
||||
SET_INSTANCE(rxbt_inst, BATT_ID, 0);
|
||||
SET_INSTANCE(rssi_inst, RSSI_ID, 24);
|
||||
@@ -410,7 +404,7 @@ void TelemetrySimulator::generateTelemetryFrame()
|
||||
if (ok && (buffer[2] || buffer[3]))
|
||||
simulator->sendTelemetry(buffer, FRSKY_SPORT_PACKET_SIZE);
|
||||
else
|
||||
onTimerEvent();
|
||||
generateTelemetryFrame();
|
||||
}
|
||||
|
||||
uint32_t TelemetrySimulator::FlvssEmulator::encodeCellPair(uint8_t cellNum, uint8_t firstCellNo, double cell1, double cell2)
|
||||
|
||||
Reference in New Issue
Block a user