Make OutputWindow a bit faster

By limiting how often we scroll to the bottom and thus limiting
how often we redraw.

Change-Id: I42ec9dc6284112025108000420ccdfdf5d003f34
Task-number: QTCREATORBUG-14307
Reviewed-by: Eike Ziller <eike.ziller@theqtcompany.com>
This commit is contained in:
Daniel Teske
2015-04-28 17:24:52 +02:00
parent 097ff14be3
commit 0e95a56121
2 changed files with 21 additions and 3 deletions

View File

@@ -127,6 +127,12 @@ OutputWindow::OutputWindow(Context context, QWidget *parent)
redoAction->setEnabled(false);
cutAction->setEnabled(false);
copyAction->setEnabled(false);
m_scrollTimer.setInterval(10);
m_scrollTimer.setSingleShot(true);
connect(&m_scrollTimer, &QTimer::timeout,
this, &OutputWindow::scrollToBottom);
m_lastMessage.start();
}
OutputWindow::~OutputWindow()
@@ -241,7 +247,7 @@ void OutputWindow::appendMessage(const QString &output, OutputFormat format)
{
const QString out = SynchronousProcess::normalizeNewlines(output);
setMaximumBlockCount(d->maxLineCount);
const bool atBottom = isScrollbarAtBottom();
const bool atBottom = isScrollbarAtBottom() || m_scrollTimer.isActive();
if (format == ErrorMessageFormat || format == NormalMessageFormat) {
@@ -281,8 +287,16 @@ void OutputWindow::appendMessage(const QString &output, OutputFormat format)
}
}
if (atBottom)
scrollToBottom();
if (atBottom) {
if (m_lastMessage.elapsed() < 5) {
m_scrollTimer.start();
} else {
m_scrollTimer.stop();
scrollToBottom();
}
}
m_lastMessage.start();
enableUndoRedo();
}