Skip to content

Commit dfb0caa

Browse files
authored
Fix: Fixed an issue where the right-click menu would sometimes freeze the app (#12686)
1 parent 13c2ee2 commit dfb0caa

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

src/Files.App/Shell/ShellNewMenuHelper.cs

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -50,22 +50,28 @@ public static async Task<ShellNewEntry> GetNewContextMenuEntryForType(string ext
5050

5151
private static async Task<ShellNewEntry> GetShellNewRegistryEntries(RegistryKey current, RegistryKey root)
5252
{
53-
foreach (var keyName in current.GetSubKeyNames())
53+
try
5454
{
55-
using var key = current.OpenSubKeySafe(keyName);
56-
57-
if (key is null)
58-
continue;
59-
60-
if (keyName == "ShellNew")
61-
return await ParseShellNewRegistryEntry(key, root);
62-
else
55+
foreach (var keyName in current.GetSubKeyNames())
6356
{
64-
var ret = await GetShellNewRegistryEntries(key, root);
65-
if (ret is not null)
66-
return ret;
57+
using var key = current.OpenSubKeySafe(keyName);
58+
59+
if (key is null)
60+
continue;
61+
62+
if (keyName == "ShellNew")
63+
return await ParseShellNewRegistryEntry(key, root);
64+
else
65+
{
66+
var ret = await GetShellNewRegistryEntries(key, root);
67+
if (ret is not null)
68+
return ret;
69+
}
6770
}
6871
}
72+
catch {
73+
// Ignore exceptions when the registry is inaccessible to avoid freezes
74+
}
6975

7076
return null;
7177
}

0 commit comments

Comments
 (0)