Clear Parent on old image source#29481
Merged
PureWeen merged 1 commit intoinflight/currentfrom May 14, 2025
Merged
Conversation
Contributor
There was a problem hiding this comment.
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
OnImageSourceChangedto clearoldSource.Parentbefore 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:
SettingNewImageeSourceshould beSettingNewImageSourceto remove the extra 'e'.
public void SettingNewImageeSourceClearsParentOnOldImageSource()
b1c4d23 to
3d62f37
Compare
mattleibow
approved these changes
May 13, 2025
PureWeen
added a commit
that referenced
this pull request
May 14, 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.