From 43cdebefa620c0fe8ad4f9db846d92061134e3f9 Mon Sep 17 00:00:00 2001
From: Tofu Linden <tofu.linden@lindenlab.com>
Date: Mon, 4 Jan 2010 14:03:02 -0800
Subject: [PATCH] EXT-3318 LLConsole keeps all logged text in memory when
 console is not being drawn.

---
 indra/llui/llconsole.cpp    | 6 ++++++
 indra/newview/llstartup.cpp | 1 +
 2 files changed, 7 insertions(+)

diff --git a/indra/llui/llconsole.cpp b/indra/llui/llconsole.cpp
index fa0abd55d02..c9090d388da 100644
--- a/indra/llui/llconsole.cpp
+++ b/indra/llui/llconsole.cpp
@@ -392,4 +392,10 @@ void LLConsole::addLine(const LLWString& wline, F32 size, const LLColor4 &color)
 	Paragraph paragraph(wline, color, mTimer.getElapsedTimeF32(), mFont,  (F32)getRect().getWidth() );
 	
 	mParagraphs.push_back ( paragraph );
+
+	// remove old paragraphs which can't possibly be visible any more.  ::draw() will do something similar but more conservative - we do this here because ::draw() isn't guaranteed to ever be called!  (i.e. the console isn't visible)
+        while ((S32)mParagraphs.size() > llmax((S32)0, (S32)(mMaxLines)))
+        {
+                mParagraphs.pop_front();
+        }
 }
diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp
index eb2275bff07..99fa271b782 100644
--- a/indra/newview/llstartup.cpp
+++ b/indra/newview/llstartup.cpp
@@ -1309,6 +1309,7 @@ bool idle_startup()
 			// Move the progress view in front of the UI
 			gViewerWindow->moveProgressViewToFront();
 
+			// direct logging to the debug console's line buffer
 			LLError::logToFixedBuffer(gDebugView->mDebugConsolep);
 			
 			// set initial visibility of debug console
-- 
GitLab