Skip to content

[Mac Catalyst] NullReferenceException in DragAndDropDelegate - FIX#28417

Merged
rmarinho merged 4 commits intodotnet:mainfrom
MartyIX:feature/2025-03-14-mac-avoid-NRE-in-HandleDropCompleted
Mar 18, 2025
Merged

[Mac Catalyst] NullReferenceException in DragAndDropDelegate - FIX#28417
rmarinho merged 4 commits intodotnet:mainfrom
MartyIX:feature/2025-03-14-mac-avoid-NRE-in-HandleDropCompleted

Conversation

@MartyIX
Copy link
Copy Markdown
Contributor

@MartyIX MartyIX commented Mar 14, 2025

Description of Change

I'm not exactly sure if the fix is correct but I have verified that it fixes the crash for my application.

Test

Drag the blue square on the silver element below and the blue square is "removed" in the drop event handler. Consequently, drag-completed handler cannot be called with the proper platform view.

image

(This is how it looks like on Windows but the bug manifests on macOS.)

Issues Fixed

Fixes #28416

@MartyIX MartyIX requested a review from a team as a code owner March 14, 2025 15:30
@dotnet-policy-service dotnet-policy-service bot added the community ✨ Community Contribution label Mar 14, 2025
{
HandleDrop(view, cdi.DataPackage, session, new PlatformDropEventArgs(cdi.View.Handler.PlatformView as UIView, interaction, session));
HandleDropCompleted(cdi.View, new PlatformDropCompletedEventArgs(cdi.View.Handler.PlatformView as UIView, interaction, session));
HandleDropCompleted(cdi.View, new PlatformDropCompletedEventArgs(cdi.View.Handler?.PlatformView as UIView, interaction, session));
Copy link
Copy Markdown
Contributor Author

@MartyIX MartyIX Mar 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fixes the bug1 for me.

Alternatively, one can extract cdi.View.Handler.PlatformView to a variable. But I'm not exactly sure what the expected behavior is.

Please tell me.

Footnotes

  1. If it is supported scenario.

@MartyIX MartyIX added platform/macos macOS / Mac Catalyst area-gestures Gesture types labels Mar 14, 2025
Copy link
Copy Markdown
Member

@rmarinho rmarinho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to add a test for this ?

@MartyIX MartyIX force-pushed the feature/2025-03-14-mac-avoid-NRE-in-HandleDropCompleted branch from 7194a89 to e1238e1 Compare March 15, 2025 20:16
@MartyIX MartyIX marked this pull request as draft March 15, 2025 20:16
@MartyIX MartyIX force-pushed the feature/2025-03-14-mac-avoid-NRE-in-HandleDropCompleted branch 4 times, most recently from c53eac9 to db379de Compare March 15, 2025 21:28
@MartyIX MartyIX marked this pull request as ready for review March 15, 2025 21:29
@MartyIX MartyIX force-pushed the feature/2025-03-14-mac-avoid-NRE-in-HandleDropCompleted branch from db379de to 4c71922 Compare March 15, 2025 21:35
@jsuarezruiz
Copy link
Copy Markdown
Contributor

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 3 pipeline(s).

rmarinho
rmarinho previously approved these changes Mar 17, 2025
@rmarinho rmarinho added this to the .NET 9 SR6 milestone Mar 17, 2025
@rmarinho rmarinho moved this from Todo to Approved in MAUI SDK Ongoing Mar 17, 2025
@MartyIX MartyIX dismissed stale reviews from rmarinho and StephaneDelcroix via 7216a9b March 17, 2025 13:08
@MartyIX MartyIX force-pushed the feature/2025-03-14-mac-avoid-NRE-in-HandleDropCompleted branch from 4c71922 to 7216a9b Compare March 17, 2025 13:08
@rmarinho
Copy link
Copy Markdown
Member

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 3 pipeline(s).

@rmarinho rmarinho merged commit 17a5744 into dotnet:main Mar 18, 2025
128 checks passed
@github-project-automation github-project-automation bot moved this from Approved to Done in MAUI SDK Ongoing Mar 18, 2025
@MartyIX MartyIX deleted the feature/2025-03-14-mac-avoid-NRE-in-HandleDropCompleted branch March 18, 2025 15:19
@github-actions github-actions bot locked and limited conversation to collaborators Apr 18, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-gestures Gesture types community ✨ Community Contribution platform/macos macOS / Mac Catalyst

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[Mac Catalyst] NullReferenceException in DragAndDropDelegate

4 participants