From c9481d44423ac2e6f03c9234da84ad61e7b71905 Mon Sep 17 00:00:00 2001 From: SpoinkyNL Date: Sat, 12 Nov 2016 19:42:08 +0100 Subject: [PATCH] Fixed debug log removing wrong line at >50 lines Wrapped LUA loading in try-catch --- .../Artemis/Controls/Log/LoggingControl.xaml | 4 ++-- .../Controls/Log/LoggingControl.xaml.cs | 2 +- Artemis/Artemis/Profiles/Lua/LuaWrapper.cs | 18 ++++++++++++------ 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/Artemis/Artemis/Controls/Log/LoggingControl.xaml b/Artemis/Artemis/Controls/Log/LoggingControl.xaml index b1ded7610..85c8b6ff9 100644 --- a/Artemis/Artemis/Controls/Log/LoggingControl.xaml +++ b/Artemis/Artemis/Controls/Log/LoggingControl.xaml @@ -16,8 +16,8 @@ - - + + diff --git a/Artemis/Artemis/Controls/Log/LoggingControl.xaml.cs b/Artemis/Artemis/Controls/Log/LoggingControl.xaml.cs index cf771ba2d..6809192cf 100644 --- a/Artemis/Artemis/Controls/Log/LoggingControl.xaml.cs +++ b/Artemis/Artemis/Controls/Log/LoggingControl.xaml.cs @@ -28,7 +28,7 @@ namespace Artemis.Controls.Log await Dispatcher.InvokeAsync(() => { if (LogCollection.Count >= 50) - LogCollection.RemoveAt(LogCollection.Count - 1); + LogCollection.RemoveAt(0); LogCollection.Add(message); }); diff --git a/Artemis/Artemis/Profiles/Lua/LuaWrapper.cs b/Artemis/Artemis/Profiles/Lua/LuaWrapper.cs index aa65ba722..284a74c94 100644 --- a/Artemis/Artemis/Profiles/Lua/LuaWrapper.cs +++ b/Artemis/Artemis/Profiles/Lua/LuaWrapper.cs @@ -97,12 +97,18 @@ namespace Artemis.Profiles.Lua LuaKeyboardWrapper?.Dispose(); LuaKeyboardWrapper = null; - LuaScript.Globals.Clear(); - LuaScript.Registry.Clear(); - LuaScript.Registry.RegisterConstants(); - LuaScript.Registry.RegisterCoreModules(CoreModules.Preset_SoftSandbox); - LuaScript.Globals.RegisterConstants(); - LuaScript.Globals.RegisterCoreModules(CoreModules.Preset_SoftSandbox); + try + { + LuaScript.Registry.RegisterConstants(); + LuaScript.Registry.RegisterCoreModules(CoreModules.Preset_SoftSandbox); + LuaScript.Globals.RegisterConstants(); + LuaScript.Globals.RegisterCoreModules(CoreModules.Preset_SoftSandbox); + } + catch (NullReferenceException) + { + // Can be missing if the user script screwed up the globals + } + } }