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,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;
|
||||
Ui.OpenWindow("MULTIPLAYER_PANEL", new WidgetArgs
|
||||
@@ -227,7 +230,6 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
{ "directConnectHost", host },
|
||||
{ "directConnectPort", port },
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
void LoadMapIntoEditor(Map map)
|
||||
@@ -362,5 +364,12 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
OpenSkirmishLobbyPanel,
|
||||
() => { 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