mirror of https://github.com/mgba-emu/mgba.git
Qt: Attempt to reduce logging overhead
This commit is contained in:
parent
0a9104113c
commit
6e7851f614
|
@ -70,15 +70,13 @@ LogView::LogView(LogController* log, QWidget* parent)
|
||||||
|
|
||||||
void LogView::postLog(int level, const QString& log) {
|
void LogView::postLog(int level, const QString& log) {
|
||||||
QString line = QString("%1:\t%2").arg(LogController::toString(level)).arg(log);
|
QString line = QString("%1:\t%2").arg(LogController::toString(level)).arg(log);
|
||||||
if (isVisible()) {
|
// TODO: Log to file
|
||||||
m_ui.view->appendPlainText(line);
|
m_pendingLines.enqueue(line);
|
||||||
} else {
|
|
||||||
m_pendingLines.enqueue(line);
|
|
||||||
}
|
|
||||||
++m_lines;
|
++m_lines;
|
||||||
if (m_lines > m_lineLimit) {
|
if (m_lines > m_lineLimit) {
|
||||||
clearLine();
|
clearLine();
|
||||||
}
|
}
|
||||||
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void LogView::clear() {
|
void LogView::clear() {
|
||||||
|
@ -145,10 +143,11 @@ void LogView::setMaxLines(int limit) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LogView::showEvent(QShowEvent*) {
|
void LogView::paintEvent(QPaintEvent* event) {
|
||||||
while (!m_pendingLines.isEmpty()) {
|
while (!m_pendingLines.isEmpty()) {
|
||||||
m_ui.view->appendPlainText(m_pendingLines.dequeue());
|
m_ui.view->appendPlainText(m_pendingLines.dequeue());
|
||||||
}
|
}
|
||||||
|
QWidget::paintEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LogView::clearLine() {
|
void LogView::clearLine() {
|
||||||
|
|
|
@ -38,7 +38,7 @@ private slots:
|
||||||
void setMaxLines(int);
|
void setMaxLines(int);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void showEvent(QShowEvent*) override;
|
virtual void paintEvent(QPaintEvent*) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static const int DEFAULT_LINE_LIMIT = 1000;
|
static const int DEFAULT_LINE_LIMIT = 1000;
|
||||||
|
|
Loading…
Reference in New Issue