Skip to content

Fix: Force Close when Rearranging Pin items in side bar #17044

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 14 additions & 10 deletions src/Files.App/Services/Windows/WindowsQuickAccessService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using Files.App.Utils.Shell;
using Files.App.UserControls.Widgets;
using Files.App.Helpers;

namespace Files.App.Services
{
Expand Down Expand Up @@ -38,7 +39,7 @@ private async Task PinToSidebarAsync(string[] folderPaths, bool doUpdateQuickAcc
App.QuickAccessManager.UpdateQuickAccessWidget?.Invoke(this, new ModifyQuickAccessEventArgs(folderPaths, true));
}

public Task UnpinFromSidebarAsync(string folderPath) => UnpinFromSidebarAsync(new[] { folderPath });
public Task UnpinFromSidebarAsync(string folderPath) => UnpinFromSidebarAsync(new[] { folderPath });

public Task UnpinFromSidebarAsync(string[] folderPaths) => UnpinFromSidebarAsync(folderPaths, true);

Expand All @@ -55,27 +56,30 @@ private async Task UnpinFromSidebarAsync(string[] folderPaths, bool doUpdateQuic

foreach (dynamic? fi in f2.Items())
{
if (ShellStorageFolder.IsShellPath((string)fi.Path))
string pathStr = (string)fi.Path;

if (ShellStorageFolder.IsShellPath(pathStr))
{
var folder = await ShellStorageFolder.FromPathAsync((string)fi.Path);
var folder = await ShellStorageFolder.FromPathAsync(pathStr);
var path = folder?.Path;

if (path is not null &&
(folderPaths.Contains(path) || (path.StartsWith(@"\\SHELL\") && folderPaths.Any(x => x.StartsWith(@"\\SHELL\"))))) // Fix for the Linux header
if (path is not null &&
(folderPaths.Contains(path) ||
(path.StartsWith(@"\\SHELL\\") && folderPaths.Any(x => x.StartsWith(@"\\SHELL\\")))))
{
await SafetyExtensions.IgnoreExceptions(async () =>
await Win32Helper.StartSTATask(async () =>
{
await fi.InvokeVerb("unpinfromhome");
fi.InvokeVerb("unpinfromhome");
});
continue;
}
}

if (folderPaths.Contains((string)fi.Path))
if (folderPaths.Contains(pathStr))
{
await SafetyExtensions.IgnoreExceptions(async () =>
await Win32Helper.StartSTATask(async () =>
{
await fi.InvokeVerb("unpinfromhome");
fi.InvokeVerb("unpinfromhome");
});
}
}
Expand Down