Skip to content

Commit d1642c2

Browse files
authored
Avoid crash when dragging files from WinRAR (#5999)
1 parent a3634ed commit d1642c2

File tree

6 files changed

+11
-0
lines changed

6 files changed

+11
-0
lines changed

Files/BaseLayout.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -879,6 +879,7 @@ protected async void Item_DragOver(object sender, DragEventArgs e)
879879
e.Handled = true;
880880

881881
var (handledByFtp, draggedItems) = await Filesystem.FilesystemHelpers.GetDraggedStorageItems(e.DataView);
882+
draggedItems ??= new List<IStorageItemWithPath>();
882883

883884
if (draggedItems.Any(draggedItem => draggedItem.Path == item.ItemPath))
884885
{

Files/Filesystem/FilesystemOperations/Helpers/FilesystemHelpers.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -583,6 +583,7 @@ public async Task<ReturnResult> CopyItemAsync(IStorageItemWithPath source, strin
583583
public async Task<ReturnResult> CopyItemsFromClipboard(DataPackageView packageView, string destination, bool showDialog, bool registerHistory)
584584
{
585585
var (handledByFtp, source) = await GetDraggedStorageItems(packageView);
586+
source ??= new List<IStorageItemWithPath>();
586587

587588
if (handledByFtp)
588589
{
@@ -814,6 +815,7 @@ public async Task<ReturnResult> MoveItemsFromClipboard(DataPackageView packageVi
814815
}
815816

816817
var (handledByFtp, source) = await GetDraggedStorageItems(packageView);
818+
source ??= new List<IStorageItemWithPath>();
817819

818820
if (handledByFtp)
819821
{
@@ -913,6 +915,7 @@ public async Task<ReturnResult> CreateShortcutFromClipboard(DataPackageView pack
913915
}
914916

915917
var (handledByFtp, source) = await GetDraggedStorageItems(packageView);
918+
source ??= new List<IStorageItemWithPath>();
916919

917920
if (handledByFtp)
918921
{
@@ -948,6 +951,7 @@ public async Task<ReturnResult> RecycleItemsFromClipboard(DataPackageView packag
948951
}
949952

950953
var (handledByFtp, source) = await GetDraggedStorageItems(packageView);
954+
source ??= new List<IStorageItemWithPath>();
951955

952956
if (handledByFtp)
953957
{

Files/Interacts/BaseLayoutCommandImplementationModel.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,7 @@ public virtual async Task DragOver(DragEventArgs e)
535535
e.Handled = true;
536536

537537
var (handledByFtp, draggedItems) = await Filesystem.FilesystemHelpers.GetDraggedStorageItems(e.DataView);
538+
draggedItems ??= new List<IStorageItemWithPath>();
538539

539540
var pwd = associatedInstance.FilesystemViewModel.WorkingDirectory.TrimPath();
540541
var folderName = (Path.IsPathRooted(pwd) && Path.GetPathRoot(pwd) == pwd) ? Path.GetPathRoot(pwd) : Path.GetFileName(pwd);

Files/UserControls/SidebarControl.xaml.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -558,6 +558,7 @@ private async void NavigationViewLocationItem_DragOver(object sender, DragEventA
558558
e.Handled = true;
559559

560560
var (handledByFtp, storageItems) = await Filesystem.FilesystemHelpers.GetDraggedStorageItems(e.DataView);
561+
storageItems ??= new List<IStorageItemWithPath>();
561562

562563
if (string.IsNullOrEmpty(locationItem.Path) ||
563564
(storageItems.Any() && storageItems.AreItemsAlreadyInFolder(locationItem.Path))
@@ -699,6 +700,7 @@ private async void NavigationViewDriveItem_DragOver(object sender, DragEventArgs
699700
e.Handled = true;
700701

701702
var (handledByFtp, storageItems) = await Filesystem.FilesystemHelpers.GetDraggedStorageItems(e.DataView);
703+
storageItems ??= new List<IStorageItemWithPath>();
702704

703705
if ("DriveCapacityUnknown".GetLocalized().Equals(driveItem.SpaceText, StringComparison.OrdinalIgnoreCase) ||
704706
(storageItems.Any() && storageItems.AreItemsAlreadyInFolder(driveItem.Path)))

Files/ViewModels/NavToolbarViewModel.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,8 @@ public async void PathBoxItem_DragOver(object sender, DragEventArgs e)
443443
var deferral = e.GetDeferral();
444444

445445
var (handledByFtp, storageItems) = await Filesystem.FilesystemHelpers.GetDraggedStorageItems(e.DataView);
446+
storageItems ??= new List<IStorageItemWithPath>();
447+
446448
if (handledByFtp)
447449
{
448450
e.AcceptedOperation = DataPackageOperation.None;

Files/ViewModels/Widgets/Bundles/BundleContainerViewModel.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,7 @@ private async Task Drop(DragEventArgs e)
312312
if (Filesystem.FilesystemHelpers.HasDraggedStorageItems(e.DataView))
313313
{
314314
var (_, items) = await Filesystem.FilesystemHelpers.GetDraggedStorageItems(e.DataView);
315+
items ??= new List<IStorageItemWithPath>();
315316

316317
if (await AddItemsFromPath(items.ToDictionary((item) => item.Path, (item) => item.ItemType)))
317318
{

0 commit comments

Comments
 (0)