From 00828765103fb295cc1895e0025cfb1a76adc0ba Mon Sep 17 00:00:00 2001 From: "andres.delikat" Date: Sat, 28 Jan 2012 21:51:01 +0000 Subject: [PATCH] LuaConsole - protect WriteToOutputWindow() and ClearOutputWindow() in case lua console is closed when called. Close the lua object on LuaConsole close (fixes some crashes). --- BizHawk.MultiClient/LuaImplementation.cs | 6 ++++++ BizHawk.MultiClient/tools/LuaConsole.cs | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/BizHawk.MultiClient/LuaImplementation.cs b/BizHawk.MultiClient/LuaImplementation.cs index 9b6087f3ca..1df35b29be 100644 --- a/BizHawk.MultiClient/LuaImplementation.cs +++ b/BizHawk.MultiClient/LuaImplementation.cs @@ -28,6 +28,12 @@ namespace BizHawk.MultiClient Caller = passed.get(); LuaRegister(lua); } + + public void Close() + { + lua.Close(); + } + public void LuaRegister(Lua lua) { lua.RegisterFunction("print", this, this.GetType().GetMethod("print")); diff --git a/BizHawk.MultiClient/tools/LuaConsole.cs b/BizHawk.MultiClient/tools/LuaConsole.cs index 69a6025f04..a43f7bd60e 100644 --- a/BizHawk.MultiClient/tools/LuaConsole.cs +++ b/BizHawk.MultiClient/tools/LuaConsole.cs @@ -104,6 +104,7 @@ namespace BizHawk.MultiClient private void SaveConfigSettings() { + LuaImp.Close(); Global.Config.LuaConsoleWndx = this.Location.X; Global.Config.LuaConsoleWndy = this.Location.Y; Global.Config.LuaConsoleWidth = this.Right - this.Left; @@ -559,12 +560,18 @@ namespace BizHawk.MultiClient public void WriteToOutputWindow(string message) { + if (!OutputBox.IsHandleCreated || OutputBox.IsDisposed) + return; + OutputBox.Text += message; OutputBox.Refresh(); } public void ClearOutputWindow() { + if (!OutputBox.IsHandleCreated || OutputBox.IsDisposed) + return; + OutputBox.Text = ""; OutputBox.Refresh(); }