Fix crash on null Logmessage
This commit is contained in:
parent
c813e1854d
commit
0552b3db82
@ -45,14 +45,22 @@ public class MemoryLogger : LoggerBase
|
||||
public string[] GetNewLines()
|
||||
{
|
||||
int logMessageCount = _logMessages.Count;
|
||||
string[] ret = new string[logMessageCount - _lastLogMessageIndex];
|
||||
List<string> ret = new();
|
||||
|
||||
for (int retIndex = 0; retIndex < ret.Length; retIndex++)
|
||||
int retIndex = 0;
|
||||
for (; retIndex < logMessageCount - _lastLogMessageIndex; retIndex++)
|
||||
{
|
||||
ret[retIndex] = _logMessages.GetValueAtIndex(_lastLogMessageIndex + retIndex).ToString();
|
||||
try
|
||||
{
|
||||
ret.Add(_logMessages.GetValueAtIndex(_lastLogMessageIndex + retIndex).ToString());
|
||||
}
|
||||
catch (NullReferenceException e)//Called when LogMessage has not finished writing
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
_lastLogMessageIndex = logMessageCount;
|
||||
return ret;
|
||||
_lastLogMessageIndex = _lastLogMessageIndex + retIndex;
|
||||
return ret.ToArray();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user