mirror of
https://github.com/EdgeTX/edgetx.git
synced 2025-07-24 00:35:14 +03:00
[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:
parent
52e65179a8
commit
4aa0c1bbe4
28 changed files with 290 additions and 210 deletions
|
@ -71,7 +71,7 @@ DebugOutput::DebugOutput(QWidget * parent, SimulatorInterface *simulator):
|
|||
ui->filterText->addItem(fltr, "no_delete");
|
||||
|
||||
ui->filterText->setValidator(new DebugOutputFilterValidator(ui->filterText));
|
||||
ui->filterText->installEventFilter(new DeleteComboBoxItemEventFilter());
|
||||
ui->filterText->installEventFilter(new DeleteComboBoxItemEventFilter(this));
|
||||
|
||||
ui->actionShowFilterHelp->setIcon(SimulatorIcon("info"));
|
||||
ui->actionWordWrap->setIcon(SimulatorIcon("word_wrap"));
|
||||
|
@ -115,6 +115,7 @@ DebugOutput::DebugOutput(QWidget * parent, SimulatorInterface *simulator):
|
|||
|
||||
DebugOutput::~DebugOutput()
|
||||
{
|
||||
m_simulator->installTraceHook(NULL);
|
||||
saveState();
|
||||
|
||||
if (AppDebugMessageHandler::instance())
|
||||
|
@ -173,15 +174,18 @@ void DebugOutput::restoreState()
|
|||
|
||||
void DebugOutput::processBytesReceived()
|
||||
{
|
||||
static char buf[512];
|
||||
const QTextCursor savedCursor(ui->console->textCursor());
|
||||
const int sbValue = ui->console->verticalScrollBar()->value();
|
||||
const bool sbAtBottom = (sbValue == ui->console->verticalScrollBar()->maximum());
|
||||
qint64 len;
|
||||
QString text;
|
||||
|
||||
while ((len = m_dataBufferDevice->bytesAvailable()) > 0) {
|
||||
QString text(m_dataBufferDevice->read(qMin(len, qint64(512))));
|
||||
if (text.isEmpty())
|
||||
while (m_dataBufferDevice && m_dataBufferDevice->bytesAvailable() > 0) {
|
||||
len = m_dataBufferDevice->read(buf, sizeof(buf));
|
||||
if (len <= 0)
|
||||
break;
|
||||
text = QString::fromLocal8Bit(buf, len);
|
||||
ui->console->moveCursor(QTextCursor::End);
|
||||
ui->console->textCursor().insertText(text);
|
||||
if (sbAtBottom) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue