From 2a383f288eeb3ac52100384122211433cc7af090 Mon Sep 17 00:00:00 2001 From: "E.Z. Hart" Date: Thu, 11 Mar 2021 10:54:49 -0700 Subject: [PATCH] Add missing lock in IStyle.Apply --- src/Controls/src/Core/Style.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Controls/src/Core/Style.cs b/src/Controls/src/Core/Style.cs index 9a3c9d912..78e17f346 100644 --- a/src/Controls/src/Core/Style.cs +++ b/src/Controls/src/Core/Style.cs @@ -85,7 +85,11 @@ namespace Microsoft.Maui.Controls void IStyle.Apply(BindableObject bindable) { - _targets.Add(new WeakReference(bindable)); + lock (_targets) + { + _targets.Add(new WeakReference(bindable)); + } + if (BaseResourceKey != null) bindable.SetDynamicResource(_basedOnResourceProperty, BaseResourceKey); ApplyCore(bindable, BasedOn ?? GetBasedOnResource(bindable));