From c9bee3dd3c1a1a132fb53182d3cdec3fc458e430 Mon Sep 17 00:00:00 2001 From: "seer-by-sentry[bot]" <157164994+seer-by-sentry[bot]@users.noreply.github.com> Date: Tue, 16 Sep 2025 19:09:21 +0000 Subject: [PATCH] Bugfix: Prevent drag and drop race condition --- .../ViewModels/Layouts/BaseLayoutViewModel.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/Files.App/ViewModels/Layouts/BaseLayoutViewModel.cs b/src/Files.App/ViewModels/Layouts/BaseLayoutViewModel.cs index c4fa685b7bae..984d49364705 100644 --- a/src/Files.App/ViewModels/Layouts/BaseLayoutViewModel.cs +++ b/src/Files.App/ViewModels/Layouts/BaseLayoutViewModel.cs @@ -101,6 +101,14 @@ public async Task DragOverAsync(DragEventArgs e) return; } + // Check if ShellViewModel is initialized to prevent race condition + if (_associatedInstance.ShellViewModel is null) + { + e.AcceptedOperation = DataPackageOperation.None; + deferral.Complete(); + return; + } + if (FilesystemHelpers.HasDraggedStorageItems(e.DataView)) { e.Handled = true; @@ -207,6 +215,13 @@ public async Task DropAsync(DragEventArgs e) } } + // Check if ShellViewModel is initialized to prevent race condition + if (_associatedInstance.ShellViewModel is null) + { + e.AcceptedOperation = DataPackageOperation.None; + return; + } + var deferral = e.GetDeferral(); try {