From 73f5f1fa75f9d2b212e59253e9f5d78d5f7b835d Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Thu, 25 Jan 2018 18:26:41 +0000 Subject: [PATCH] Remove AddChatLine registration on IngameChatLogic dispose. --- .../Widgets/Logic/Ingame/IngameChatLogic.cs | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/OpenRA.Mods.Common/Widgets/Logic/Ingame/IngameChatLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Ingame/IngameChatLogic.cs index 407014583a..0f7b473b0a 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Ingame/IngameChatLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Ingame/IngameChatLogic.cs @@ -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); + } } }