Skip to content

Commit 2133b53

Browse files
authored
Fix: Fixed crash that could occur when adding items to the jumplist (#15670)
1 parent 880900f commit 2133b53

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

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

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,23 +30,26 @@ public async Task InitializeAsync()
3030

3131
public async Task AddFolderAsync(string path)
3232
{
33-
if (JumpList.IsSupported())
33+
try
3434
{
35-
var instance = await JumpList.LoadCurrentAsync();
36-
// Disable automatic jumplist. It doesn't work.
37-
instance.SystemGroupKind = JumpListSystemGroupKind.None;
38-
39-
// Saving to jumplist may fail randomly with error: ERROR_UNABLE_TO_REMOVE_REPLACED
40-
// In that case app should just catch the error and proceed as usual
41-
try
35+
if (JumpList.IsSupported())
4236
{
37+
var instance = await JumpList.LoadCurrentAsync();
38+
// Disable automatic jumplist. It doesn't work.
39+
instance.SystemGroupKind = JumpListSystemGroupKind.None;
40+
41+
// Saving to jumplist may fail randomly with error: ERROR_UNABLE_TO_REMOVE_REPLACED
42+
// In that case app should just catch the error and proceed as usual
4343
if (instance is not null)
4444
{
4545
AddFolder(path, JumpListRecentGroupHeader, instance);
4646
await instance.SaveAsync();
4747
}
4848
}
49-
catch { }
49+
}
50+
catch (Exception ex)
51+
{
52+
App.Logger.LogWarning(ex, ex.Message);
5053
}
5154
}
5255

@@ -123,7 +126,7 @@ private void AddFolder(string path, string group, JumpList instance)
123126

124127
if (path.StartsWith("\\\\SHELL", StringComparison.OrdinalIgnoreCase))
125128
displayName = "ThisPC".GetLocalizedResource();
126-
129+
127130
if (path.EndsWith('\\'))
128131
{
129132
var drivesViewModel = Ioc.Default.GetRequiredService<DrivesViewModel>();

0 commit comments

Comments
 (0)