Remove event handler when disposed in MainMenuLogic.

Removes a static event handler to Game.OnRemoteDirectConnect which allow the GC to reclaim the MainMenuLogic class after it has been disposed.
This commit is contained in:
RoosterDragon
2015-11-01 17:50:38 +00:00
parent 9f728b287b
commit 6f09d1a2f4

View File

@@ -217,7 +217,10 @@ namespace OpenRA.Mods.Common.Widgets.Logic
} }
} }
Game.OnRemoteDirectConnect += (host, port) => Game.OnRemoteDirectConnect += OnRemoteDirectConnect;
}
void OnRemoteDirectConnect(string host, int port)
{ {
menuType = MenuType.None; menuType = MenuType.None;
Ui.OpenWindow("MULTIPLAYER_PANEL", new WidgetArgs Ui.OpenWindow("MULTIPLAYER_PANEL", new WidgetArgs
@@ -227,7 +230,6 @@ namespace OpenRA.Mods.Common.Widgets.Logic
{ "directConnectHost", host }, { "directConnectHost", host },
{ "directConnectPort", port }, { "directConnectPort", port },
}); });
};
} }
void LoadMapIntoEditor(Map map) void LoadMapIntoEditor(Map map)
@@ -362,5 +364,12 @@ namespace OpenRA.Mods.Common.Widgets.Logic
OpenSkirmishLobbyPanel, OpenSkirmishLobbyPanel,
() => { Game.CloseServer(); menuType = MenuType.Main; }); () => { Game.CloseServer(); menuType = MenuType.Main; });
} }
protected override void Dispose(bool disposing)
{
if (disposing)
Game.OnRemoteDirectConnect -= OnRemoteDirectConnect;
base.Dispose(disposing);
}
} }
} }