From e4ab15ccb1385c2ada97bc659845ea522268682e Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Sat, 7 Feb 2009 15:51:00 +0000 Subject: Fix a .NET issue where changing a locked reference would cause a crash --- OpenSim/Framework/Console/ConsoleBase.cs | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Framework/Console/ConsoleBase.cs b/OpenSim/Framework/Console/ConsoleBase.cs index f990748..380894d 100644 --- a/OpenSim/Framework/Console/ConsoleBase.cs +++ b/OpenSim/Framework/Console/ConsoleBase.cs @@ -703,8 +703,11 @@ namespace OpenSim.Framework.Console System.Console.CursorLeft = 0; // Needed for mono System.Console.Write(" "); // Needed for mono - y = System.Console.CursorTop; - cmdline = new StringBuilder(); + lock (cmdline) + { + y = System.Console.CursorTop; + cmdline.Remove(0, cmdline.Length); + } while(true) { @@ -754,7 +757,8 @@ namespace OpenSim.Framework.Console break; historyLine--; LockOutput(); - cmdline = new StringBuilder(history[historyLine]); + cmdline.Remove(0, cmdline.Length); + cmdline.Append(history[historyLine]); cp = cmdline.Length; UnlockOutput(); break; @@ -764,9 +768,14 @@ namespace OpenSim.Framework.Console historyLine++; LockOutput(); if (historyLine == history.Count) - cmdline = new StringBuilder(); + { + cmdline.Remove(0, cmdline.Length); + } else - cmdline = new StringBuilder(history[historyLine]); + { + cmdline.Remove(0, cmdline.Length); + cmdline.Append(history[historyLine]); + } cp = cmdline.Length; UnlockOutput(); break; @@ -784,7 +793,10 @@ namespace OpenSim.Framework.Console System.Console.WriteLine("{0}{1}", prompt, cmdline); - y = -1; + lock (cmdline) + { + y = -1; + } if (isCommand) { -- cgit v1.1