forked from qt-creator/qt-creator
debugger: improve performance of output pane
Change-Id: I5417c3bb36ba399b5687f9aa51ba17a973a32a40 Reviewed-by: hjk <qthjk@ovi.com>
This commit is contained in:
@@ -402,25 +402,42 @@ void LogWindow::showOutput(int channel, const QString &output)
|
|||||||
{
|
{
|
||||||
if (output.isEmpty())
|
if (output.isEmpty())
|
||||||
return;
|
return;
|
||||||
QTextCursor oldCursor = m_combinedText->textCursor();
|
|
||||||
QTextCursor cursor = oldCursor;
|
|
||||||
cursor.movePosition(QTextCursor::End);
|
|
||||||
bool atEnd = oldCursor.position() == cursor.position();
|
|
||||||
|
|
||||||
if (debuggerCore()->boolSetting(LogTimeStamps))
|
QTextCursor cursor = m_combinedText->textCursor();
|
||||||
m_combinedText->appendPlainText(charForChannel(LogTime) + logTimeStamp());
|
const bool atEnd = cursor.atEnd();
|
||||||
foreach (QString line, output.split(QLatin1Char('\n'))) {
|
|
||||||
// FIXME: QTextEdit asserts on really long lines...
|
const QChar cchar = charForChannel(channel);
|
||||||
const int n = 30000;
|
const QChar nchar = QLatin1Char('\n');
|
||||||
if (line.size() > n) {
|
|
||||||
line.truncate(n);
|
QString out;
|
||||||
line += QLatin1String(" [...] <cut off>");
|
out.reserve(output.size() + 1000);
|
||||||
}
|
|
||||||
if (line != QLatin1String("(gdb) "))
|
if (output.at(0) != QLatin1Char('~') && debuggerCore()->boolSetting(LogTimeStamps)) {
|
||||||
m_combinedText->appendPlainText(charForChannel(channel) + line);
|
out.append(charForChannel(LogTime));
|
||||||
|
out.append(logTimeStamp());
|
||||||
|
out.append(nchar);
|
||||||
}
|
}
|
||||||
cursor.movePosition(QTextCursor::End);
|
|
||||||
|
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));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pos = nnpos + 1;
|
||||||
|
}
|
||||||
|
m_combinedText->appendPlainText(out);
|
||||||
|
|
||||||
if (atEnd) {
|
if (atEnd) {
|
||||||
|
cursor.movePosition(QTextCursor::End);
|
||||||
m_combinedText->setTextCursor(cursor);
|
m_combinedText->setTextCursor(cursor);
|
||||||
m_combinedText->ensureCursorVisible();
|
m_combinedText->ensureCursorVisible();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user