Commit 3e0d666f authored by hjk's avatar hjk
Browse files

debugger: improve performance of output pane



Change-Id: I5417c3bb36ba399b5687f9aa51ba17a973a32a40
Reviewed-by: default avatarhjk <qthjk@ovi.com>
parent 0495649c
......@@ -402,25 +402,42 @@ void LogWindow::showOutput(int channel, const QString &output)
{
if (output.isEmpty())
return;
QTextCursor oldCursor = m_combinedText->textCursor();
QTextCursor cursor = oldCursor;
cursor.movePosition(QTextCursor::End);
bool atEnd = oldCursor.position() == cursor.position();
if (debuggerCore()->boolSetting(LogTimeStamps))
m_combinedText->appendPlainText(charForChannel(LogTime) + logTimeStamp());
foreach (QString line, output.split(QLatin1Char('\n'))) {
// FIXME: QTextEdit asserts on really long lines...
const int n = 30000;
if (line.size() > n) {
line.truncate(n);
line += QLatin1String(" [...] <cut off>");
QTextCursor cursor = m_combinedText->textCursor();
const bool atEnd = cursor.atEnd();
const QChar cchar = charForChannel(channel);
const QChar nchar = QLatin1Char('\n');
QString out;
out.reserve(output.size() + 1000);
if (output.at(0) != QLatin1Char('~') && debuggerCore()->boolSetting(LogTimeStamps)) {
out.append(charForChannel(LogTime));
out.append(logTimeStamp());
out.append(nchar);
}
for (int pos = 0, n = output.size(); pos < n; ) {
const int npos = output.indexOf(nchar, pos);
const int nnpos = npos == -1 ? n : npos;
const int l = nnpos - pos;
if (l != 6 || output.midRef(pos, 6) != QLatin1String("(gdb) ")) {
out.append(cchar);
if (l > 30000) {
// FIXME: QTextEdit asserts on really long lines...
out.append(output.midRef(pos, 30000));
out.append(QLatin1String(" [...] <cut off>\n"));
} else {
out.append(output.midRef(pos, l + 1));
}
}
if (line != QLatin1String("(gdb) "))
m_combinedText->appendPlainText(charForChannel(channel) + line);
pos = nnpos + 1;
}
cursor.movePosition(QTextCursor::End);
m_combinedText->appendPlainText(out);
if (atEnd) {
cursor.movePosition(QTextCursor::End);
m_combinedText->setTextCursor(cursor);
m_combinedText->ensureCursorVisible();
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment