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:
@@ -8,6 +8,7 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Scripting;
|
||||
using OpenRA.Traits;
|
||||
@@ -21,7 +22,7 @@ namespace OpenRA.Mods.RA.Scripting
|
||||
public object Create(ActorInitializer init) { return new LuaScript(this); }
|
||||
}
|
||||
|
||||
public class LuaScript : ITick, IWorldLoaded
|
||||
public sealed class LuaScript : ITick, IWorldLoaded, IDisposable
|
||||
{
|
||||
readonly LuaScriptInfo info;
|
||||
ScriptContext context;
|
||||
@@ -42,5 +43,11 @@ namespace OpenRA.Mods.RA.Scripting
|
||||
{
|
||||
context.Tick(self);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (context != null)
|
||||
context.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user