Skip to content

Commit a5a43f4

Browse files
authored
Fixed a crash that would sometimes occur when copying items to usb drives (#1780)
1 parent 36511c8 commit a5a43f4

File tree

5 files changed

+13
-10
lines changed

5 files changed

+13
-10
lines changed

Files/BaseLayout.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -221,21 +221,22 @@ protected override async void OnNavigatedTo(NavigationEventArgs eventArgs)
221221
await App.CurrentInstance.FilesystemViewModel.SetWorkingDirectory(parameters);
222222

223223
// pathRoot will be empty on recycle bin path
224-
string pathRoot = Path.GetPathRoot(App.CurrentInstance.FilesystemViewModel.WorkingDirectory);
225-
if (string.IsNullOrEmpty(pathRoot) || App.CurrentInstance.FilesystemViewModel.WorkingDirectory == pathRoot)
224+
var workingDir = App.CurrentInstance.FilesystemViewModel.WorkingDirectory;
225+
string pathRoot = Path.GetPathRoot(workingDir);
226+
if (string.IsNullOrEmpty(pathRoot) || workingDir == pathRoot)
226227
{
227228
App.CurrentInstance.NavigationToolbar.CanNavigateToParent = false;
228229
}
229230
else
230231
{
231232
App.CurrentInstance.NavigationToolbar.CanNavigateToParent = true;
232233
}
234+
233235
App.CurrentInstance.InstanceViewModel.IsPageTypeNotHome = true; // show controls that were hidden on the home page
234-
App.CurrentInstance.InstanceViewModel.IsPageTypeRecycleBin =
235-
App.CurrentInstance.FilesystemViewModel.WorkingDirectory.StartsWith(App.AppSettings.RecycleBinPath);
236-
App.CurrentInstance.InstanceViewModel.IsPageTypeMtpDevice =
237-
App.CurrentInstance.FilesystemViewModel.WorkingDirectory.StartsWith("\\\\?\\");
236+
App.CurrentInstance.InstanceViewModel.IsPageTypeRecycleBin = workingDir.StartsWith(App.AppSettings.RecycleBinPath);
237+
App.CurrentInstance.InstanceViewModel.IsPageTypeMtpDevice = workingDir.StartsWith("\\\\?\\");
238238

239+
await App.CurrentInstance.MultitaskingControl?.SetSelectedTabInfo(new DirectoryInfo(workingDir).Name, workingDir);
239240
App.CurrentInstance.FilesystemViewModel.RefreshItems();
240241

241242
App.CurrentInstance.MultitaskingControl?.SelectionChanged();

Files/UserControls/MultitaskingControl/HorizontalMultitaskingControl.xaml.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using System.Collections.ObjectModel;
1010
using System.IO;
1111
using System.Linq;
12+
using System.Threading.Tasks;
1213
using Windows.ApplicationModel.DataTransfer;
1314
using Windows.Storage;
1415
using Windows.UI.ViewManagement;
@@ -36,7 +37,7 @@ public HorizontalMultitaskingControl()
3637
private const string TabDropHandledIdentifier = "FilesTabViewItemDropHandled";
3738
public ObservableCollection<TabItem> Items => MainPage.AppInstances;
3839

39-
public async void SetSelectedTabInfo(string text, string currentPathForTabIcon)
40+
public async Task SetSelectedTabInfo(string text, string currentPathForTabIcon)
4041
{
4142
var selectedTabItem = (MainPage.AppInstances[App.InteractionViewModel.TabStripSelectedIndex] as TabItem);
4243
selectedTabItem.AllowStorageItemDrop = App.CurrentInstance.InstanceViewModel.IsPageTypeNotHome;

Files/UserControls/MultitaskingControl/IMultitaskingControl.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
using System.Collections.ObjectModel;
2+
using System.Threading.Tasks;
23

34
namespace Files.UserControls.MultiTaskingControl
45
{
56
public interface IMultitaskingControl
67
{
7-
void SetSelectedTabInfo(string text, string currentPathForTabIcon);
8+
Task SetSelectedTabInfo(string text, string currentPathForTabIcon);
89

910
void SelectionChanged();
1011

Files/UserControls/MultitaskingControl/VerticalTabView.xaml.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using System.Collections.ObjectModel;
99
using System.IO;
1010
using System.Linq;
11+
using System.Threading.Tasks;
1112
using Windows.ApplicationModel.DataTransfer;
1213
using Windows.Storage;
1314
using Windows.UI.Xaml;
@@ -31,7 +32,7 @@ public VerticalTabView()
3132
this.InitializeComponent();
3233
}
3334

34-
public async void SetSelectedTabInfo(string text, string currentPathForTabIcon = null)
35+
public async Task SetSelectedTabInfo(string text, string currentPathForTabIcon = null)
3536
{
3637
var selectedTabItem = (MainPage.AppInstances[App.InteractionViewModel.TabStripSelectedIndex] as TabItem);
3738
selectedTabItem.AllowStorageItemDrop = App.CurrentInstance.InstanceViewModel.IsPageTypeNotHome;

Files/View Models/ItemViewModel.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,6 @@ public async void RapidAddItemsToCollectionAsync(string path)
541541
{
542542
App.CurrentInstance.NavigationToolbar.CanRefresh = false;
543543

544-
App.CurrentInstance.MultitaskingControl?.SetSelectedTabInfo(new DirectoryInfo(path).Name, path);
545544
CancelLoadAndClearFiles();
546545

547546
try

0 commit comments

Comments
 (0)