Debugger: Force shrinking of internal structures of log pane.

Just keeping a maximum number of lines is not enough.

Task-number: QTCREATORBUG-4620
Change-Id: Iedb947dc55e55fa3717da88c4e5762526423bbb6
Reviewed-by: hjk <hjk121@nokiamail.com>
This commit is contained in:
hjk
2013-02-27 16:12:28 +01:00
parent 287ba032ab
commit e395af1ac1

View File

@@ -189,11 +189,18 @@ public:
void append(const QString &text) void append(const QString &text)
{ {
const int N = 100000; const int N = 100000;
if (blockCount() > N) { const int bc = blockCount();
QTextBlock block = document()->findBlock(9 * N / 10); if (bc > N) {
QTextDocument *doc = document();
QTextBlock block = doc->findBlockByLineNumber(bc * 9 / 10);
QTextCursor tc(block); QTextCursor tc(block);
tc.movePosition(QTextCursor::Start, QTextCursor::MoveAnchor); tc.movePosition(QTextCursor::Start, QTextCursor::KeepAnchor);
tc.removeSelectedText(); tc.removeSelectedText();
// Seems to be the only way to force shrinking of the
// allocated data.
QString contents = doc->toHtml();
doc->clear();
doc->setHtml(contents);
} }
appendPlainText(text); appendPlainText(text);
} }