From da360bcd1870650848daa034aa31b8a337caecc7 Mon Sep 17 00:00:00 2001 From: yum Date: Sun, 10 Sep 2023 03:50:46 -0700 Subject: Bugfix: only cap display of transcript at 4K chars Actually retain the whole transcript to avoid breaking the OSC pager. Also constrain the UI buffer size by characters instead of lines. Since some lines can be massive and others short, characters are a better way of consistently keeping the UI memory in check. --- GUI/GUI/GUI/Logging.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'GUI') diff --git a/GUI/GUI/GUI/Logging.cpp b/GUI/GUI/GUI/Logging.cpp index f6ad3ab..6983a40 100644 --- a/GUI/GUI/GUI/Logging.cpp +++ b/GUI/GUI/GUI/Logging.cpp @@ -51,13 +51,14 @@ void Logging::ThreadLogger::Drain() // Constrain wxTextCtrl's to a few hundred lines to keep memory usage / // general snappiness in check. if (frame) { - wxString allText = frame->GetValue(); - wxArrayString lines = wxStringTokenize(allText, "\n"); - size_t count = lines.GetCount(); - constexpr int kHalfMaxLines = 1000; - if (count > kHalfMaxLines * 2) { + constexpr int kHalfMaxChars = 50 * 1000; + int nchars; + while ((nchars = frame->GetLastPosition()) > kHalfMaxChars) { + wxString allText = frame->GetValue(); + wxArrayString lines = wxStringTokenize(allText, "\n"); // Keep only the last kHalfMaxLines lines. - size_t linesToRemove = count - kHalfMaxLines; + size_t nlines = lines.GetCount(); + size_t linesToRemove = nlines / 2; // Remove lines from the beginning lines.RemoveAt(0, linesToRemove); -- cgit v1.2.3