Skip to content

Commit f006d34

Browse files
committed
Fix
1 parent 6038b2c commit f006d34

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/Files.App.CsWin32/NativeMethods.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,3 +156,4 @@ IApplicationDestinations
156156
ApplicationDestinations
157157
IApplicationDocumentLists
158158
ApplicationDocumentLists
159+
ILFree

src/Files.App/Services/Windows/WindowsWallpaperService.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,10 @@ public unsafe void SetDesktopSlideshow(string[] aszPaths)
6363
(void**)pDesktopWallpaper.GetAddressOf())
6464
.ThrowOnFailure();
6565

66-
uint dwCount = (uint)aszPaths.Length;
67-
ITEMIDLIST** ppItemIdList = stackalloc ITEMIDLIST*[dwCount];
66+
ITEMIDLIST** ppItemIdList = stackalloc ITEMIDLIST*[aszPaths.Length];
6867

6968
// Get array of PIDL from the selected image files
70-
for (uint dwIndex = 0u; dwIndex < dwCount; dwIndex++)
69+
for (uint dwIndex = 0u; dwIndex < (uint)aszPaths.Length; dwIndex++)
7170
ppItemIdList[dwIndex] = PInvoke.ILCreateFromPath(aszPaths[dwIndex]);
7271

7372
// Get a shell array of the array of the PIDL
@@ -78,8 +77,8 @@ public unsafe void SetDesktopSlideshow(string[] aszPaths)
7877
hr = pDesktopWallpaper.Get()->SetSlideshow(pShellItemArray.Get()).ThrowOnFailure();
7978

8079
// Free the allocated PIDL
81-
for (uint dwIndex = 0u; dwIndex < dwCount; dwIndex++)
82-
ILFree(ppItemIdList[dwIndex]);
80+
for (uint dwIndex = 0u; dwIndex < (uint)aszPaths.Length; dwIndex++)
81+
PInvoke.ILFree(ppItemIdList[dwIndex]);
8382

8483
// Set wallpaper position to fill the monitor.
8584
hr = pDesktopWallpaper.Get()->SetPosition(DESKTOP_WALLPAPER_POSITION.DWPOS_FILL).ThrowOnFailure();

0 commit comments

Comments
 (0)