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,17 +217,19 @@ namespace OpenRA.Mods.Common.Widgets.Logic
} }
} }
Game.OnRemoteDirectConnect += (host, port) => Game.OnRemoteDirectConnect += OnRemoteDirectConnect;
}
void OnRemoteDirectConnect(string host, int port)
{
menuType = MenuType.None;
Ui.OpenWindow("MULTIPLAYER_PANEL", new WidgetArgs
{ {
menuType = MenuType.None; { "onStart", RemoveShellmapUI },
Ui.OpenWindow("MULTIPLAYER_PANEL", new WidgetArgs { "onExit", () => menuType = MenuType.Main },
{ { "directConnectHost", host },
{ "onStart", RemoveShellmapUI }, { "directConnectPort", port },
{ "onExit", () => menuType = MenuType.Main }, });
{ "directConnectHost", host },
{ "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);
}
} }
} }