From 6e7851f6142a9657213de4714c3de453b229e8d7 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Wed, 20 Jan 2016 21:22:04 -0800 Subject: [PATCH] Qt: Attempt to reduce logging overhead --- src/platform/qt/LogView.cpp | 11 +++++------ src/platform/qt/LogView.h | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/platform/qt/LogView.cpp b/src/platform/qt/LogView.cpp index cc34ea1ca..3abead151 100644 --- a/src/platform/qt/LogView.cpp +++ b/src/platform/qt/LogView.cpp @@ -70,15 +70,13 @@ LogView::LogView(LogController* log, QWidget* parent) void LogView::postLog(int level, const QString& log) { QString line = QString("%1:\t%2").arg(LogController::toString(level)).arg(log); - if (isVisible()) { - m_ui.view->appendPlainText(line); - } else { - m_pendingLines.enqueue(line); - } + // TODO: Log to file + m_pendingLines.enqueue(line); ++m_lines; if (m_lines > m_lineLimit) { clearLine(); } + update(); } 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()) { m_ui.view->appendPlainText(m_pendingLines.dequeue()); } + QWidget::paintEvent(event); } void LogView::clearLine() { diff --git a/src/platform/qt/LogView.h b/src/platform/qt/LogView.h index 2a84168c8..afc89af01 100644 --- a/src/platform/qt/LogView.h +++ b/src/platform/qt/LogView.h @@ -38,7 +38,7 @@ private slots: void setMaxLines(int); protected: - virtual void showEvent(QShowEvent*) override; + virtual void paintEvent(QPaintEvent*) override; private: static const int DEFAULT_LINE_LIMIT = 1000;