Skip to content

Commit

Permalink
Fix: Fixed an issue where the right-click menu would sometimes freeze…
Browse files Browse the repository at this point in the history
… the app (#12686)
  • Loading branch information
hishitetsu authored Jun 22, 2023
1 parent 13c2ee2 commit dfb0caa
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions src/Files.App/Shell/ShellNewMenuHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,22 +50,28 @@ public static async Task<ShellNewEntry> GetNewContextMenuEntryForType(string ext

private static async Task<ShellNewEntry> GetShellNewRegistryEntries(RegistryKey current, RegistryKey root)
{
foreach (var keyName in current.GetSubKeyNames())
try
{
using var key = current.OpenSubKeySafe(keyName);

if (key is null)
continue;

if (keyName == "ShellNew")
return await ParseShellNewRegistryEntry(key, root);
else
foreach (var keyName in current.GetSubKeyNames())
{
var ret = await GetShellNewRegistryEntries(key, root);
if (ret is not null)
return ret;
using var key = current.OpenSubKeySafe(keyName);

if (key is null)
continue;

if (keyName == "ShellNew")
return await ParseShellNewRegistryEntry(key, root);
else
{
var ret = await GetShellNewRegistryEntries(key, root);
if (ret is not null)
return ret;
}
}
}
catch {
// Ignore exceptions when the registry is inaccessible to avoid freezes
}

return null;
}
Expand Down

0 comments on commit dfb0caa

Please sign in to comment.