Skip to content

Commit 1de1109

Browse files
Code Quality: Prevent drag and drop race condition (#17625)
Co-authored-by: seer-by-sentry[bot] <157164994+seer-by-sentry[bot]@users.noreply.github.com>
1 parent ef69591 commit 1de1109

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/Files.App/ViewModels/Layouts/BaseLayoutViewModel.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,14 @@ public async Task DragOverAsync(DragEventArgs e)
101101
return;
102102
}
103103

104+
// Check if ShellViewModel is initialized to prevent race condition
105+
if (_associatedInstance.ShellViewModel is null)
106+
{
107+
e.AcceptedOperation = DataPackageOperation.None;
108+
deferral.Complete();
109+
return;
110+
}
111+
104112
if (FilesystemHelpers.HasDraggedStorageItems(e.DataView))
105113
{
106114
e.Handled = true;
@@ -207,6 +215,13 @@ public async Task DropAsync(DragEventArgs e)
207215
}
208216
}
209217

218+
// Check if ShellViewModel is initialized to prevent race condition
219+
if (_associatedInstance.ShellViewModel is null)
220+
{
221+
e.AcceptedOperation = DataPackageOperation.None;
222+
return;
223+
}
224+
210225
var deferral = e.GetDeferral();
211226
try
212227
{

0 commit comments

Comments
 (0)