Code:
|
private static void CacheFreezable(Freezable freezable, int index) |
The logic is backwards in that it only caches if the indexed value is not null, versus caching if the indexed value is null. This will result in freezable values never being cached and any calls to GetCachedFreezable will always return a null value causing brushes to be created every time a rendering pass is performed for the specific theme.
The code should instead be:
private static void CacheFreezable(Freezable freezable, int index)
{
Debug.Assert(freezable.IsFrozen, "Cached Freezables should be frozen.");
lock (_cacheAccess)
{
if (_freezableCache[index] == null)
{
_freezableCache[index] = freezable;
}
}
}