1
0
Fork 0

Enhanced LogView performance

This commit is contained in:
mappa 2019-11-04 19:22:34 +01:00 committed by Duncan Ogilvie
parent 6da9fc8b42
commit 52af639cc4
2 changed files with 8 additions and 3 deletions

View File

@ -266,7 +266,7 @@ void LogView::addMsgToLogSlot(QByteArray msg)
if(redirectError)
msgUtf16.append(tr("fwrite() failed (GetLastError()= %1 ). Log redirection stopped.\n").arg(GetLastError()));
if(logBuffer.length() >= 1024 * 1024 * 100) // 100mb buffer limit
if(logBuffer.length() >= MAX_LOG_BUFFER_SIZE)
logBuffer.clear();
logBuffer.append(msgUtf16);
@ -434,13 +434,16 @@ void LogView::flushTimerSlot()
counter--;
if(counter == 0)
{
if(document()->characterCount() > 1024 * 1024 * 100) //limit the log to ~100mb
if(document()->characterCount() > MAX_LOG_BUFFER_SIZE)
clear();
counter = 100;
}
QTextCursor cursor = textCursor();
QTextCursor cursor(document());
cursor.movePosition(QTextCursor::End);
cursor.beginEditBlock();
cursor.insertBlock();
cursor.insertHtml(logBuffer);
cursor.endEditBlock();
if(autoScroll)
moveCursor(QTextCursor::End);
setUpdatesEnabled(true);

View File

@ -35,6 +35,8 @@ public slots:
void flushLogSlot();
private:
static const int MAX_LOG_BUFFER_SIZE = 1024 * 1024;
bool loggingEnabled;
bool autoScroll;
bool utf16Redirect = false;