|
12 | 12 | using Microsoft.UI.Xaml.Media; |
13 | 13 | using Microsoft.UI.Xaml.Navigation; |
14 | 14 | using System.Runtime.InteropServices; |
15 | | -using Windows.ApplicationModel.DataTransfer; |
16 | 15 | using Windows.Foundation.Metadata; |
17 | 16 | using Windows.Graphics; |
18 | 17 | using Windows.UI.Input; |
@@ -508,26 +507,30 @@ private void SidebarControl_ItemContextInvoked(object sender, ItemContextInvoked |
508 | 507 |
|
509 | 508 | private async void SidebarControl_ItemDragOver(object sender, ItemDragOverEventArgs e) |
510 | 509 | { |
511 | | - // Expected to fail with COMException if the OLE drag payload is stale |
512 | | - var deferral = SafetyExtensions.IgnoreExceptions(() => e.RawEvent.GetDeferral(), App.Logger, typeof(COMException)); |
| 510 | + // GetDeferral()/Complete() can throw COMException if the underlying drag operation has already been released (e.g. canceled by the system or window closed) |
| 511 | + var deferral = SafetyExtensions.IgnoreExceptions(() => e.RawEvent.GetDeferral(), App.Logger); |
513 | 512 |
|
514 | | - await SafetyExtensions.IgnoreExceptions( |
515 | | - () => SidebarAdaptiveViewModel.HandleItemDragOverAsync(e), App.Logger); |
| 513 | + await SafetyExtensions.IgnoreExceptions(async () => |
| 514 | + { |
| 515 | + await SidebarAdaptiveViewModel.HandleItemDragOverAsync(e); |
| 516 | + }, App.Logger); |
516 | 517 |
|
517 | 518 | if (deferral is not null) |
518 | | - SafetyExtensions.IgnoreExceptions(() => deferral.Complete(), App.Logger, typeof(COMException)); |
| 519 | + SafetyExtensions.IgnoreExceptions(() => deferral.Complete(), App.Logger); |
519 | 520 | } |
520 | 521 |
|
521 | 522 | private async void SidebarControl_ItemDropped(object sender, ItemDroppedEventArgs e) |
522 | 523 | { |
523 | | - // Expected to fail with COMException if the OLE drag payload is stale |
524 | | - var deferral = SafetyExtensions.IgnoreExceptions(() => e.RawEvent.GetDeferral(), App.Logger, typeof(COMException)); |
| 524 | + // GetDeferral()/Complete() can throw COMException if the underlying drag operation has already been released (e.g. canceled by the system or window closed) |
| 525 | + var deferral = SafetyExtensions.IgnoreExceptions(() => e.RawEvent.GetDeferral(), App.Logger); |
525 | 526 |
|
526 | | - await SafetyExtensions.IgnoreExceptions( |
527 | | - () => SidebarAdaptiveViewModel.HandleItemDroppedAsync(e), App.Logger); |
| 527 | + await SafetyExtensions.IgnoreExceptions(async () => |
| 528 | + { |
| 529 | + await SidebarAdaptiveViewModel.HandleItemDroppedAsync(e); |
| 530 | + }, App.Logger); |
528 | 531 |
|
529 | 532 | if (deferral is not null) |
530 | | - SafetyExtensions.IgnoreExceptions(() => deferral.Complete(), App.Logger, typeof(COMException)); |
| 533 | + SafetyExtensions.IgnoreExceptions(() => deferral.Complete(), App.Logger); |
531 | 534 | } |
532 | 535 |
|
533 | 536 | private void SidebarControl_ItemInvoked(object sender, ItemInvokedEventArgs e) |
|
0 commit comments