forked from qt-creator/qt-creator
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:
@@ -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);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user