Skip to content

Commit 5c16b86

Browse files
committed
Fix file lock during file stream
1 parent 80c283a commit 5c16b86

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

Flow.Launcher/Helper/WallpaperPathRetrieval.cs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,15 @@ public static Brush GetWallpaperBrush()
4848
return cachedWallpaper;
4949
}
5050
}
51-
52-
using var fileStream = File.OpenRead(wallpaperPath);
53-
var decoder = BitmapDecoder.Create(fileStream, BitmapCreateOptions.DelayCreation, BitmapCacheOption.None);
54-
var frame = decoder.Frames[0];
55-
var originalWidth = frame.PixelWidth;
56-
var originalHeight = frame.PixelHeight;
51+
52+
int originalWidth, originalHeight;
53+
using (var fileStream = File.OpenRead(wallpaperPath))
54+
{
55+
var decoder = BitmapDecoder.Create(fileStream, BitmapCreateOptions.DelayCreation, BitmapCacheOption.None);
56+
var frame = decoder.Frames[0];
57+
originalWidth = frame.PixelWidth;
58+
originalHeight = frame.PixelHeight;
59+
}
5760

5861
if (originalWidth == 0 || originalHeight == 0)
5962
{

0 commit comments

Comments
 (0)