fix #2921: crash when support power instance vanishes while tooltip is shown

This commit is contained in:
Chris Forbes
2013-04-02 19:20:24 +13:00
parent f556be975c
commit 772efb98d4
2 changed files with 4 additions and 1 deletions

View File

@@ -39,6 +39,9 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
if (sp == null) if (sp == null)
return; return;
if (sp.Info == null)
return; // no instances actually exist (race with destroy)
time = "{0} / {1}".F(WidgetUtils.FormatTime(sp.RemainingTime), time = "{0} / {1}".F(WidgetUtils.FormatTime(sp.RemainingTime),
WidgetUtils.FormatTime(sp.Info.ChargeTime*25)); WidgetUtils.FormatTime(sp.Info.ChargeTime*25));

View File

@@ -122,7 +122,7 @@ namespace OpenRA.Mods.RA
public bool Active { get; private set; } public bool Active { get; private set; }
public bool Disabled { 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 bool Ready { get { return Active && RemainingTime == 0; } }
public SupportPowerInstance(string key, SupportPowerManager manager) public SupportPowerInstance(string key, SupportPowerManager manager)