Remove event handlers to CellEntryChanged when done.

Several classes would attach event handlers to the Map which would live longer then they did. Detaching them when no longer needed allows the GC to reclaim them.
This commit is contained in:
RoosterDragon
2015-11-01 17:21:42 +00:00
parent c562b8c51e
commit 9f728b287b
4 changed files with 17 additions and 2 deletions

View File

@@ -442,5 +442,12 @@ namespace OpenRA.Mods.Common.Widgets
var v = (int)((p.Y - mapRect.Y) / previewScale) + world.Map.Bounds.Top;
return new MPos(u, v).ToCPos(world.Map);
}
public override void Removed()
{
base.Removed();
world.Map.MapTiles.Value.CellEntryChanged -= UpdateTerrainCell;
world.Map.CustomTerrain.CellEntryChanged -= UpdateTerrainCell;
}
}
}