From 6e37d6945e1a92a938d78f45327626337eeff41f Mon Sep 17 00:00:00 2001 From: Marco Franzen Date: Mon, 14 Aug 2023 16:17:14 +0200 Subject: [PATCH] Fix: Fixed crash that would occur when deleting or restoring files (#13195) --- src/Files.App/Data/Items/LocationItem.cs | 15 ++++++++++++--- src/Files.App/Data/Models/SidebarPinnedModel.cs | 5 ----- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/Files.App/Data/Items/LocationItem.cs b/src/Files.App/Data/Items/LocationItem.cs index 78cf1c37041b..8990698b5516 100644 --- a/src/Files.App/Data/Items/LocationItem.cs +++ b/src/Files.App/Data/Items/LocationItem.cs @@ -87,7 +87,7 @@ public bool IsExpanded public bool IsHeader { get; set; } private object toolTip = ""; - public object ToolTip + public virtual object ToolTip { get => toolTip; set @@ -109,7 +109,10 @@ public class RecycleBinLocationItem : LocationItem { public void RefreshSpaceUsed(object sender, FileSystemEventArgs e) { - SpaceUsed = RecycleBinHelpers.GetSize(); + MainWindow.Instance.DispatcherQueue.TryEnqueue(() => + { + SpaceUsed = RecycleBinHelpers.GetSize(); + }); } private ulong spaceUsed; @@ -118,10 +121,16 @@ public ulong SpaceUsed get => spaceUsed; set { - SetProperty(ref spaceUsed, value); + if (SetProperty(ref spaceUsed, value)) + OnPropertyChanged(nameof(ToolTip)); } } + public override object ToolTip + { + get => SpaceUsed.ToSizeString(); + } + public RecycleBinLocationItem() { SpaceUsed = RecycleBinHelpers.GetSize(); diff --git a/src/Files.App/Data/Models/SidebarPinnedModel.cs b/src/Files.App/Data/Models/SidebarPinnedModel.cs index 05003bf47e73..f4fde71fe99f 100644 --- a/src/Files.App/Data/Models/SidebarPinnedModel.cs +++ b/src/Files.App/Data/Models/SidebarPinnedModel.cs @@ -97,11 +97,6 @@ public async Task CreateLocationItemFromPathAsync(string path) locationItem.IsDefaultLocation = false; locationItem.Text = res.Result?.DisplayName ?? Path.GetFileName(path.TrimEnd('\\')); - if(locationItem is RecycleBinLocationItem recycleBinItem) - { - recycleBinItem.ToolTip = recycleBinItem.SpaceUsed.ToSizeString(); - } - if (res || (FilesystemResult)FolderHelpers.CheckFolderAccessWithWin32(path)) { locationItem.IsInvalid = false;