-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Conversation
There was a problem hiding this 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 clearoldSource.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 beSettingNewImageSource
to remove the extra 'e'.
public void SettingNewImageeSourceClearsParentOnOldImageSource()
b1c4d23
to
3d62f37
Compare
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.