From 0c9689b371b5ff8e3dc27be4650593de340e7f1f Mon Sep 17 00:00:00 2001 From: tstellanova Date: Sat, 27 Jul 2013 22:45:18 -0700 Subject: [PATCH] Fix autoscroll stopping in message view under high load Anton and I noticed that the message view stops autoscrolling properly sometimes when there's a high frequency of arriving messages. This should fix that problem. --- src/ui/uas/QGCMessageView.cc | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/ui/uas/QGCMessageView.cc b/src/ui/uas/QGCMessageView.cc index fcd0f18d7..67a28216f 100644 --- a/src/ui/uas/QGCMessageView.cc +++ b/src/ui/uas/QGCMessageView.cc @@ -4,6 +4,7 @@ #include "UASManager.h" #include "QGCUnconnectedInfoWidget.h" #include +#include QGCMessageView::QGCMessageView(QWidget *parent) : QWidget(parent), @@ -55,9 +56,18 @@ void QGCMessageView::handleTextMessage(int uasid, int componentid, int severity, { // XXX color messages according to severity - ui->plainTextEdit->appendHtml(QString("[%2:%3] %4\n").arg(UASManager::instance()->getUASForId(uasid)->getColor().name()).arg(UASManager::instance()->getUASForId(uasid)->getUASName()).arg(componentid).arg(text)); + QPlainTextEdit *msgWidget = ui->plainTextEdit; + + //turn off updates while we're appending content to avoid breaking the autoscroll behavior + msgWidget->setUpdatesEnabled(false); + QScrollBar *scroller = msgWidget->verticalScrollBar(); + + UASInterface *uas = UASManager::instance()->getUASForId(uasid); + msgWidget->appendHtml(QString("[%2:%3] %4\n").arg(uas->getColor().name()).arg(uas->getUASName()).arg(componentid).arg(text)); // Ensure text area scrolls correctly - ui->plainTextEdit->ensureCursorVisible(); + scroller->setValue(scroller->maximum()); + msgWidget->setUpdatesEnabled(true); + } void QGCMessageView::contextMenuEvent(QContextMenuEvent* event) -- 2.22.0