Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed spare Element checking in OnDetachedFrom #2132

Merged

Conversation

rafalka
Copy link
Contributor

@rafalka rafalka commented Aug 19, 2024

Description of Change

Take look into OnDetachedFrom()

	protected override void OnDetachedFrom(VisualElement bindable, AView platformView)
	{
		base.OnDetachedFrom(bindable, platformView);

		view = platformView;

		if (Element is null)
		{
			return;
		}
...

We exiting when Element is null.
The thing is that Element is always null because it returns a View and base.OnDetachedFrom() calls UnassignViewAndBingingContext() which sets it to null.

Linked Issues

PR Checklist

  • [x ] Has a linked Issue, and the Issue has been approved(bug) or Championed (feature/proposal)
  • Has tests (if omitted, state reason in description)
  • Has samples (if omitted, state reason in description)
  • [x ] Rebased on top of main at time of PR
  • [ x] Changes adhere to coding standard
  • Documentation created or updated: https://github.com/MicrosoftDocs/CommunityToolkit/pulls

Sample code is not needed. You can check it using a CommunityToolkit.Maui.Sample by placing a breakpoint at
TouchBehaviou.android.cs:76 (or somewhere else in OnDetachedFrom()) and checking an Element.

Additional information

Copy link
Contributor

@bijington bijington left a comment

Choose a reason for hiding this comment

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

LGTM! Thank you

@brminnick brminnick enabled auto-merge (squash) August 21, 2024 19:57
@brminnick brminnick merged commit 6486b6d into CommunityToolkit:main Aug 21, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] TouchBehavior Memory Leak once the behavior has been included in a DataTemplate
3 participants