From 772efb98d4d09b19162f44e531f005d3c21b16c6 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Tue, 2 Apr 2013 19:20:24 +1300 Subject: [PATCH] fix #2921: crash when support power instance vanishes while tooltip is shown --- OpenRA.Mods.Cnc/Widgets/Logic/SupportPowerTooltipLogic.cs | 3 +++ OpenRA.Mods.RA/SupportPowers/SupportPowerManager.cs | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/OpenRA.Mods.Cnc/Widgets/Logic/SupportPowerTooltipLogic.cs b/OpenRA.Mods.Cnc/Widgets/Logic/SupportPowerTooltipLogic.cs index 37f285b449..e54cf36e36 100644 --- a/OpenRA.Mods.Cnc/Widgets/Logic/SupportPowerTooltipLogic.cs +++ b/OpenRA.Mods.Cnc/Widgets/Logic/SupportPowerTooltipLogic.cs @@ -39,6 +39,9 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic if (sp == null) return; + if (sp.Info == null) + return; // no instances actually exist (race with destroy) + time = "{0} / {1}".F(WidgetUtils.FormatTime(sp.RemainingTime), WidgetUtils.FormatTime(sp.Info.ChargeTime*25)); diff --git a/OpenRA.Mods.RA/SupportPowers/SupportPowerManager.cs b/OpenRA.Mods.RA/SupportPowers/SupportPowerManager.cs index d6b91090a8..c3c34b4f2c 100755 --- a/OpenRA.Mods.RA/SupportPowers/SupportPowerManager.cs +++ b/OpenRA.Mods.RA/SupportPowers/SupportPowerManager.cs @@ -122,7 +122,7 @@ namespace OpenRA.Mods.RA public bool Active { get; private set; } public bool Disabled { get; private set; } - public SupportPowerInfo Info { get { return Instances.First().Info; } } + public SupportPowerInfo Info { get { return Instances.Select(i => i.Info).FirstOrDefault(); } } public bool Ready { get { return Active && RemainingTime == 0; } } public SupportPowerInstance(string key, SupportPowerManager manager)