Skip to content

Commit 3ec7396

Browse files
authored
Fixed a crash that sometimes occurs when pressing Ctrl + C / V / X (#1996)
1 parent 4f6351f commit 3ec7396

File tree

5 files changed

+10
-5
lines changed

5 files changed

+10
-5
lines changed

Files/Commands/Paste.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,15 @@ public static async void PasteItemWithStatus(DataPackageView packageView, string
5353

5454
private static async Task PasteItem(DataPackageView packageView, string destinationPath, DataPackageOperation acceptedOperation, IShellPage AppInstance, IProgress<uint> progress)
5555
{
56-
IReadOnlyList<IStorageItem> itemsToPaste = await packageView.GetStorageItemsAsync();
57-
5856
if (!packageView.Contains(StandardDataFormats.StorageItems))
5957
{
6058
// Happens if you copy some text and then you Ctrl+V in FilesUWP
6159
// Should this be done in ModernShellPage?
6260
return;
6361
}
62+
63+
IReadOnlyList<IStorageItem> itemsToPaste = await packageView.GetStorageItemsAsync();
64+
6465
if (AppInstance.FilesystemViewModel.WorkingDirectory.StartsWith(App.AppSettings.RecycleBinPath))
6566
{
6667
// Do not paste files and folders inside the recycle bin

Files/Dialogs/BitlockerDialog.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ private void BitlockerInput_TextChanged(object sender, Windows.UI.Xaml.RoutedEve
4747
{
4848
if (e.Key.Equals(VirtualKey.Enter))
4949
{
50-
var element = Windows.UI.Xaml.Input.FocusManager.GetFocusedElement(XamlRoot) as Button;
50+
var element = Windows.UI.Xaml.Input.FocusManager.GetFocusedElement() as Button;
5151
if (element == null || element.Name == "PrimaryButton")
5252
{
5353
if (!IsPrimaryButtonEnabled) return;

Files/Interacts/Interaction.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -974,6 +974,10 @@ public async void CutItem_Click(object sender, RoutedEventArgs e)
974974
return;
975975
}
976976
}
977+
if (!items.Any())
978+
{
979+
return;
980+
}
977981
dataPackage.SetStorageItems(items);
978982
Clipboard.SetContent(dataPackage);
979983
try

Files/Views/LayoutModes/GenericFileBrowser.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ protected override void Page_CharacterReceived(CoreWindow sender, CharacterRecei
411411
{
412412
if (App.CurrentInstance.CurrentPageType == typeof(GenericFileBrowser))
413413
{
414-
var focusedElement = FocusManager.GetFocusedElement(XamlRoot) as FrameworkElement;
414+
var focusedElement = FocusManager.GetFocusedElement() as FrameworkElement;
415415
if (focusedElement is TextBox || focusedElement is PasswordBox ||
416416
Interacts.Interaction.FindParent<ContentDialog>(focusedElement) != null)
417417
{

Files/Views/LayoutModes/GridViewBrowser.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ protected override void Page_CharacterReceived(CoreWindow sender, CharacterRecei
303303
{
304304
if (App.CurrentInstance.CurrentPageType == typeof(GridViewBrowser) && !isRenamingItem)
305305
{
306-
var focusedElement = FocusManager.GetFocusedElement(XamlRoot) as FrameworkElement;
306+
var focusedElement = FocusManager.GetFocusedElement() as FrameworkElement;
307307
if (focusedElement is TextBox || focusedElement is PasswordBox ||
308308
Interacts.Interaction.FindParent<ContentDialog>(focusedElement) != null)
309309
{

0 commit comments

Comments
 (0)