diff options
author | hjk <hjk121@nokiamail.com> | 2013-02-27 16:12:28 +0100 |
---|---|---|
committer | hjk <hjk121@nokiamail.com> | 2013-02-27 16:14:52 +0100 |
commit | e395af1ac175d174e78138d974435a2556e775cd (patch) | |
tree | 302db4464c90da798a390fbb6d9657533ddeb05e /src/plugins/debugger/logwindow.cpp | |
parent | 287ba032ab13f5199f529bb5102bc19944304550 (diff) |
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>
Diffstat (limited to 'src/plugins/debugger/logwindow.cpp')
-rw-r--r-- | src/plugins/debugger/logwindow.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/plugins/debugger/logwindow.cpp b/src/plugins/debugger/logwindow.cpp index 237a7af6cb..862c229e38 100644 --- a/src/plugins/debugger/logwindow.cpp +++ b/src/plugins/debugger/logwindow.cpp @@ -189,11 +189,18 @@ public: void append(const QString &text) { const int N = 100000; - if (blockCount() > N) { - QTextBlock block = document()->findBlock(9 * N / 10); + const int bc = blockCount(); + if (bc > N) { + QTextDocument *doc = document(); + QTextBlock block = doc->findBlockByLineNumber(bc * 9 / 10); QTextCursor tc(block); - tc.movePosition(QTextCursor::Start, QTextCursor::MoveAnchor); + tc.movePosition(QTextCursor::Start, QTextCursor::KeepAnchor); 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); } |