Skip to content

Clear Parent on old image source #29481

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

Merged
merged 1 commit into from
May 14, 2025

Conversation

PureWeen
Copy link
Member

Description of Change

Currently we aren't clearing the parent out on image sources when they are swapped out on images. This is causing old image sources to "leak" via "AddResourcesChangedListener" until the page is popped.

@Copilot Copilot AI review requested due to automatic review settings May 13, 2025 23:25
@PureWeen PureWeen requested a review from a team as a code owner May 13, 2025 23:25
@PureWeen PureWeen requested review from jfversluis and mattleibow May 13, 2025 23:25
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR ensures that when an image’s source is swapped, the previous ImageSource.Parent reference is cleared to prevent resource leaks and verifies the new source’s parent is correctly assigned.

  • Added a unit test that checks old source parent is cleared and new source parent is set.
  • Updated OnImageSourceChanged to clear oldSource.Parent before handling the new source.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/Controls/tests/Core.UnitTests/ImageSourceTests.cs Added SettingNewImageSourceClearsParentOnOldImageSource test case
src/Controls/src/Core/ImageElement.cs In OnImageSourceChanged, clear oldSource.Parent when swapping sources
Comments suppressed due to low confidence (1)

src/Controls/tests/Core.UnitTests/ImageSourceTests.cs:172

  • Typo in the test method name: SettingNewImageeSource should be SettingNewImageSource to remove the extra 'e'.
public void SettingNewImageeSourceClearsParentOnOldImageSource()

@PureWeen PureWeen force-pushed the clear_parent_on_old_imagesource branch from b1c4d23 to 3d62f37 Compare May 13, 2025 23:37
@PureWeen PureWeen changed the base branch from main to inflight/current May 14, 2025 03:41
@PureWeen PureWeen merged commit c51c832 into inflight/current May 14, 2025
124 of 129 checks passed
@PureWeen PureWeen deleted the clear_parent_on_old_imagesource branch May 14, 2025 03:41
PureWeen added a commit that referenced this pull request May 14, 2025
github-actions bot pushed a commit that referenced this pull request May 15, 2025
PureWeen added a commit that referenced this pull request May 21, 2025
PureWeen added a commit that referenced this pull request May 21, 2025
github-actions bot pushed a commit that referenced this pull request May 22, 2025
github-actions bot pushed a commit that referenced this pull request May 30, 2025
github-actions bot pushed a commit that referenced this pull request May 30, 2025
@github-actions github-actions bot locked and limited conversation to collaborators Jun 13, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants