Skip to content

Commit 7c81536

Browse files
authored
Fix: Fixed NullReferenceException in PinnedFoldersManager.CreateLocationItemFromPathAsync (#15956)
1 parent 23c58be commit 7c81536

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/Files.App/Data/Models/PinnedFoldersManager.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,12 @@ public async Task<LocationItem> CreateLocationItemFromPathAsync(string path)
9393
ShowEmptyRecycleBin = string.Equals(path, Constants.UserEnvironmentPaths.RecycleBinPath, StringComparison.OrdinalIgnoreCase)
9494
};
9595
locationItem.IsDefaultLocation = false;
96-
locationItem.Text = res.Result?.DisplayName ?? Path.GetFileName(path.TrimEnd('\\'));
96+
locationItem.Text = res?.Result?.DisplayName ?? Path.GetFileName(path.TrimEnd('\\'));
9797

9898
if (res)
9999
{
100100
locationItem.IsInvalid = false;
101-
if (res && res.Result is not null)
101+
if (res.Result is not null)
102102
{
103103
var result = await FileThumbnailHelper.GetIconAsync(
104104
res.Result.Path,
@@ -117,7 +117,7 @@ public async Task<LocationItem> CreateLocationItemFromPathAsync(string path)
117117
{
118118
locationItem.Icon = await MainWindow.Instance.DispatcherQueue.EnqueueOrInvokeAsync(() => UIHelpers.GetSidebarIconResource(Constants.ImageRes.Folder));
119119
locationItem.IsInvalid = true;
120-
Debug.WriteLine($"Pinned item was invalid {res.ErrorCode}, item: {path}");
120+
Debug.WriteLine($"Pinned item was invalid {res?.ErrorCode}, item: {path}");
121121
}
122122

123123
return locationItem;

0 commit comments

Comments
 (0)