Skip to content

Commit

Permalink
fix(dragdrop): Fix possible null ref in Drag and Drop
Browse files Browse the repository at this point in the history
  • Loading branch information
dr1rrb committed Dec 14, 2020
1 parent e53bfaa commit aa9c8b4
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/Uno.UI/UI/Xaml/Controls/ListViewBase/ListViewBase.DragDrop.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ private void PrepareContainerForDragDrop(UIElement itemContainer)

private static void PrepareContainerForDragDropCore(UIElement itemContainer)
{
if (itemContainer is null) // Even if flagged as impossible by nullable check, https://github.com/unoplatform/uno/issues/4725
{
return;
}

// Known issue: the ContainerClearedForItem might not be invoked properly for all items on some platforms.
// This patch is acceptable as event handlers are static (so they won't leak).
itemContainer.DragStarting -= OnItemContainerDragStarting;
Expand All @@ -92,6 +97,11 @@ private static void PrepareContainerForDragDropCore(UIElement itemContainer)

private static void ClearContainerForDragDrop(UIElement itemContainer)
{
if (itemContainer is null) // Even if flagged as impossible by nullable check, https://github.com/unoplatform/uno/issues/4725
{
return;
}

itemContainer.DragStarting -= OnItemContainerDragStarting;
itemContainer.DropCompleted -= OnItemContainerDragCompleted;

Expand Down

0 comments on commit aa9c8b4

Please sign in to comment.