Fixed IDisposable implementation and usage.
- Implement IDisposable interface correctly, with sealed classes where possible for simplicity. - Add using statement around undisposed local variables.
This commit is contained in:
@@ -18,7 +18,7 @@ using OpenRA.Primitives;
|
||||
|
||||
namespace OpenRA.Mods.RA.Scripting
|
||||
{
|
||||
public class LuaScriptContext : IDisposable
|
||||
public sealed class LuaScriptContext : IDisposable
|
||||
{
|
||||
public Lua Lua { get; private set; }
|
||||
readonly Cache<string, LuaFunction> functionCache;
|
||||
@@ -133,19 +133,9 @@ namespace OpenRA.Mods.RA.Scripting
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (Lua == null)
|
||||
return;
|
||||
|
||||
GC.SuppressFinalize(this);
|
||||
Lua.Dispose();
|
||||
Lua = null;
|
||||
}
|
||||
|
||||
~LuaScriptContext()
|
||||
{
|
||||
if (Lua != null)
|
||||
Game.RunAfterTick(Dispose);
|
||||
Lua.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user