Skip to content

Commit

Permalink
LT-21882: Add lock
Browse files Browse the repository at this point in the history
Add a lock to GetBestUniqueNameForNode() to protect against
potential additional callers.  Currently the only caller
already established a lock.

Change-Id: Id8721fd2982c5e62c4aa8ffb22e4d3d2e2ac2e76
  • Loading branch information
mark-sil authored and jasonleenaylor committed Dec 5, 2024
1 parent 0d462ed commit a543f08
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions Src/xWorks/CssGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,16 +124,19 @@ public string GetBestUniqueNameForNode(ConfigurableDictionaryNode node)

string classNameBase = className;
int counter = 0;
while (_styleDictionary.ContainsKey(className))
lock (_styleDictionary)
{
var styleContent = GenerateCssFromConfigurationNode(node, className, _propertyTable).NonEmpty();
if (AreStyleRulesListsEquivalent(_styleDictionary[className], styleContent))
while (_styleDictionary.ContainsKey(className))
{
return className;
var styleContent = GenerateCssFromConfigurationNode(node, className, _propertyTable).NonEmpty();
if (AreStyleRulesListsEquivalent(_styleDictionary[className], styleContent))
{
return className;
}
className = $"{classNameBase}-{++counter}";
}
className = $"{classNameBase}-{++counter}";
_styleDictionary[className] = GenerateCssFromConfigurationNode(node, className, _propertyTable).NonEmpty();
}
_styleDictionary[className] = GenerateCssFromConfigurationNode(node, className, _propertyTable).NonEmpty();
return className;
}

Expand Down

0 comments on commit a543f08

Please sign in to comment.