From bc5efa3fc54303a7d96cec00a4222264bd99e5c9 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Fri, 4 Nov 2011 19:03:38 +1300 Subject: [PATCH] #1241 fixed - crash in ChooseBuildTabOnSelect.SelectionChanged --- OpenRA.Mods.RA/World/ChooseBuildTabOnSelect.cs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/OpenRA.Mods.RA/World/ChooseBuildTabOnSelect.cs b/OpenRA.Mods.RA/World/ChooseBuildTabOnSelect.cs index a4678d0e5d..74ce6f0a64 100644 --- a/OpenRA.Mods.RA/World/ChooseBuildTabOnSelect.cs +++ b/OpenRA.Mods.RA/World/ChooseBuildTabOnSelect.cs @@ -31,14 +31,17 @@ namespace OpenRA.Mods.RA public void SelectionChanged() { + var palette = Widget.RootWidget.GetWidget("INGAME_BUILD_PALETTE"); + if (palette == null) + return; + // Queue-per-structure var perqueue = world.Selection.Actors.FirstOrDefault( a => a.IsInWorld && a.World.LocalPlayer == a.Owner && a.HasTrait()); if (perqueue != null) { - Widget.RootWidget.GetWidget("INGAME_BUILD_PALETTE") - .SetCurrentTab(perqueue.TraitsImplementing().First()); + palette.SetCurrentTab(perqueue.TraitsImplementing().First()); return; } @@ -51,9 +54,8 @@ namespace OpenRA.Mods.RA if (types.Length == 0) return; - Widget.RootWidget.GetWidget("INGAME_BUILD_PALETTE") - .SetCurrentTab(world.LocalPlayer.PlayerActor.TraitsImplementing() - .FirstOrDefault(t => types.Contains(t.Info.Type))); + palette.SetCurrentTab(world.LocalPlayer.PlayerActor.TraitsImplementing() + .FirstOrDefault(t => types.Contains(t.Info.Type))); } } }