Remove AddChatLine registration on IngameChatLogic dispose.

This commit is contained in:
Paul Chote
2018-01-25 18:26:41 +00:00
committed by reaperrr
parent 5f54e46eae
commit 73f5f1fa75

View File

@@ -145,7 +145,6 @@ namespace OpenRA.Mods.Common.Widgets.Logic
AddChatLine(chatLine.Color, chatLine.Name, chatLine.Text, true);
orderManager.AddChatLine += AddChatLineWrapper;
Game.BeforeGameStart += UnregisterEvents;
chatText.IsDisabled = () => world.IsReplay && !Game.Settings.Debug.EnableDebugCommandsInReplays;
@@ -177,12 +176,6 @@ namespace OpenRA.Mods.Common.Widgets.Logic
return true;
}
void UnregisterEvents()
{
orderManager.AddChatLine -= AddChatLineWrapper;
Game.BeforeGameStart -= UnregisterEvents;
}
public void OpenChat()
{
chatText.Text = "";
@@ -246,5 +239,17 @@ namespace OpenRA.Mods.Common.Widgets.Logic
if (!replayCache)
Game.Sound.PlayNotification(modRules, null, "Sounds", "ChatLine", null);
}
bool disposed = false;
protected override void Dispose(bool disposing)
{
if (!disposed)
{
orderManager.AddChatLine -= AddChatLineWrapper;
disposed = true;
}
base.Dispose(disposing);
}
}
}