LuaConsole - protect WriteToOutputWindow() and ClearOutputWindow() in case lua console is closed when called. Close the lua object on LuaConsole close (fixes some crashes).

This commit is contained in:
andres.delikat 2012-01-28 21:51:01 +00:00
parent 41708a8579
commit 0082876510
2 changed files with 13 additions and 0 deletions

View File

@ -28,6 +28,12 @@ namespace BizHawk.MultiClient
Caller = passed.get(); Caller = passed.get();
LuaRegister(lua); LuaRegister(lua);
} }
public void Close()
{
lua.Close();
}
public void LuaRegister(Lua lua) public void LuaRegister(Lua lua)
{ {
lua.RegisterFunction("print", this, this.GetType().GetMethod("print")); lua.RegisterFunction("print", this, this.GetType().GetMethod("print"));

View File

@ -104,6 +104,7 @@ namespace BizHawk.MultiClient
private void SaveConfigSettings() private void SaveConfigSettings()
{ {
LuaImp.Close();
Global.Config.LuaConsoleWndx = this.Location.X; Global.Config.LuaConsoleWndx = this.Location.X;
Global.Config.LuaConsoleWndy = this.Location.Y; Global.Config.LuaConsoleWndy = this.Location.Y;
Global.Config.LuaConsoleWidth = this.Right - this.Left; Global.Config.LuaConsoleWidth = this.Right - this.Left;
@ -559,12 +560,18 @@ namespace BizHawk.MultiClient
public void WriteToOutputWindow(string message) public void WriteToOutputWindow(string message)
{ {
if (!OutputBox.IsHandleCreated || OutputBox.IsDisposed)
return;
OutputBox.Text += message; OutputBox.Text += message;
OutputBox.Refresh(); OutputBox.Refresh();
} }
public void ClearOutputWindow() public void ClearOutputWindow()
{ {
if (!OutputBox.IsHandleCreated || OutputBox.IsDisposed)
return;
OutputBox.Text = ""; OutputBox.Text = "";
OutputBox.Refresh(); OutputBox.Refresh();
} }