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:
@@ -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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user