From 24712825ebf8923d1834dd45df38f42cea676773 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Sat, 7 May 2011 19:50:54 +1200 Subject: [PATCH] Throw a useful exception on duplicated widget Id. --- OpenRA.Game/Widgets/WidgetLoader.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/OpenRA.Game/Widgets/WidgetLoader.cs b/OpenRA.Game/Widgets/WidgetLoader.cs index 662148918e..d01bd82318 100644 --- a/OpenRA.Game/Widgets/WidgetLoader.cs +++ b/OpenRA.Game/Widgets/WidgetLoader.cs @@ -24,7 +24,12 @@ namespace OpenRA { foreach( var file in modData.Manifest.ChromeLayout.Select( a => MiniYaml.FromFile( a ) ) ) foreach( var w in file ) - widgets.Add( w.Key.Substring( w.Key.IndexOf( '@' ) + 1 ), w ); + { + var key = w.Key.Substring( w.Key.IndexOf( '@' ) + 1 ); + if (widgets.ContainsKey(key)) + throw new InvalidDataException("Widget has duplicate Key `{0}`".F(w.Key)); + widgets.Add( key, w ); + } } public Widget LoadWidget( Dictionary args, Widget parent, string w )