Skip to content

Commit 9e7d704

Browse files
authored
Fix: Fixed issue where icon overlays were cached (#14727)
1 parent 1ebfec4 commit 9e7d704

File tree

2 files changed

+1
-33
lines changed

2 files changed

+1
-33
lines changed

src/Files.App/Helpers/BitmapHelper.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ internal static class BitmapHelper
2828
{
2929
image.DecodePixelWidth = decodeSize;
3030
image.DecodePixelHeight = decodeSize;
31+
image.DecodePixelType = DecodePixelType.Logical;
3132
}
3233
await image.SetSourceAsync(ms.AsRandomAccessStream());
3334
return image;

src/Files.App/Utils/Shell/Win32API.cs

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -217,14 +217,6 @@ public static string ExtractStringFromDLL(string file, int number)
217217
}
218218
}
219219

220-
private class IconAndOverlayCacheEntry
221-
{
222-
public byte[]? Icon { get; set; }
223-
224-
public byte[]? Overlay { get; set; }
225-
}
226-
227-
private static readonly ConcurrentDictionary<string, ConcurrentDictionary<int, IconAndOverlayCacheEntry>> _iconAndOverlayCache = new();
228220

229221
private static readonly object _lock = new object();
230222

@@ -254,20 +246,6 @@ public static (byte[]? icon, byte[]? overlay, bool isIconCached) GetFileIconAndO
254246
byte[]? iconData = null, overlayData = null;
255247
bool isIconCached = false;
256248

257-
var entry = _iconAndOverlayCache.GetOrAdd(path, _ => new());
258-
259-
if (entry.TryGetValue(thumbnailSize, out var cacheEntry))
260-
{
261-
iconData = cacheEntry.Icon;
262-
overlayData = cacheEntry.Overlay;
263-
264-
if ((onlyGetOverlay && overlayData is not null) ||
265-
(!getOverlay && iconData is not null) ||
266-
(overlayData is not null && iconData is not null))
267-
{
268-
return (iconData, overlayData, true);
269-
}
270-
}
271249

272250
try
273251
{
@@ -386,14 +364,7 @@ public static (byte[]? icon, byte[]? overlay, bool isIconCached) GetFileIconAndO
386364
}
387365
finally
388366
{
389-
cacheEntry = new IconAndOverlayCacheEntry();
390-
if (iconData is not null)
391-
cacheEntry.Icon = iconData;
392-
393-
if (overlayData is not null)
394-
cacheEntry.Overlay = overlayData;
395367

396-
entry[thumbnailSize] = cacheEntry;
397368
}
398369
}
399370

@@ -525,8 +496,6 @@ public static bool SetCustomDirectoryIcon(string? folderPath, string? iconFile,
525496
fcs.dwSize = (uint)Marshal.SizeOf(fcs);
526497

527498
var success = Shell32.SHGetSetFolderCustomSettings(ref fcs, folderPath, Shell32.FCS.FCS_FORCEWRITE).Succeeded;
528-
if (success)
529-
_iconAndOverlayCache[folderPath] = new();
530499

531500
return success;
532501
}
@@ -537,8 +506,6 @@ public static bool SetCustomFileIcon(string? filePath, string? iconFile, int ico
537506
return false;
538507

539508
var success = FileOperationsHelpers.SetLinkIcon(filePath, iconFile, iconIndex);
540-
if (success)
541-
_iconAndOverlayCache[filePath] = new();
542509

543510
return success;
544511
}

0 commit comments

Comments
 (0)