Skip to content

Commit db3145e

Browse files
MailaenderPunkPun
authored andcommitted
Evaluate read only dictionaries.
1 parent e49135b commit db3145e

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

OpenRA.Mods.Common/Widgets/Logic/Settings/DisplaySettingsLogic.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
using System;
1313
using System.Collections.Generic;
14+
using System.Collections.ObjectModel;
1415
using System.Linq;
1516
using OpenRA.Graphics;
1617
using OpenRA.Mods.Common.Traits;
@@ -510,8 +511,9 @@ static void RecalculateWidgetLayout(Widget w, bool insideScrollPanel = false)
510511
{ "PARENT_BOTTOM", parentBounds.Height }
511512
};
512513

513-
var width = w.Width.Evaluate(substitutions);
514-
var height = w.Height.Evaluate(substitutions);
514+
var readOnlySubstitutions = new ReadOnlyDictionary<string, int>(substitutions);
515+
var width = w.Width != null ? w.Width.Evaluate(readOnlySubstitutions) : 0;
516+
var height = w.Height != null ? w.Height.Evaluate(readOnlySubstitutions) : 0;
515517

516518
substitutions.Add("WIDTH", width);
517519
substitutions.Add("HEIGHT", height);
@@ -520,8 +522,8 @@ static void RecalculateWidgetLayout(Widget w, bool insideScrollPanel = false)
520522
w.Bounds = new Rectangle(w.Bounds.X, w.Bounds.Y, width, w.Bounds.Height);
521523
else
522524
w.Bounds = new Rectangle(
523-
w.X.Evaluate(substitutions),
524-
w.Y.Evaluate(substitutions),
525+
w.X != null ? w.X.Evaluate(readOnlySubstitutions) : 0,
526+
w.Y != null ? w.Y.Evaluate(readOnlySubstitutions) : 0,
525527
width,
526528
height);
527529

0 commit comments

Comments
 (0)