Skip to content

Fix Button Regression with null image source#25485

Merged
PureWeen merged 5 commits into
release/9.0.1xxfrom
dev/TJ/ButtonImageSourceRegression_SR9
Oct 25, 2024
Merged

Fix Button Regression with null image source#25485
PureWeen merged 5 commits into
release/9.0.1xxfrom
dev/TJ/ButtonImageSourceRegression_SR9

Conversation

@tj-devel709

Copy link
Copy Markdown
Member

This PR fixes an null reference issue that occurs when an button has its image set by UIButton.SetImage. Instead of using the Button.ImageSource.ToString() to see if the image has changed without needing to hold a reference to the image, the code now uses the UIButton.CurrentImage hash to determine if the image has changed. This helps us know if the image was changed in those situations where the Button.ImageSource is null but the UIButton.CurrentImage is still set.

Description of Change

Issues Fixed

Fixes #25409

@tj-devel709 tj-devel709 requested a review from a team as a code owner October 23, 2024 22:06
@tj-devel709 tj-devel709 requested review from jfversluis and rmarinho and removed request for a team October 23, 2024 22:06
#if IOS
((Action)(async () =>
{
var imageSource = new FileImageSource() { File = "shopping_cart.png" };

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could the test be extended to:

  • Set the image when the button is tapped.
  • Remove the image, setting a null value when tapping again.
  • Reset the image by tapping the button again (for example, using a counter, odd sets image, even removes it).
    ?

@tj-devel709 tj-devel709 force-pushed the dev/TJ/ButtonImageSourceRegression_SR9 branch from e8b6993 to 7807d75 Compare October 24, 2024 17:19
@tj-devel709 tj-devel709 force-pushed the dev/TJ/ButtonImageSourceRegression_SR9 branch from 7807d75 to cc5dc08 Compare October 24, 2024 17:25
@tj-devel709 tj-devel709 requested a review from a team as a code owner October 24, 2024 17:25
@tj-devel709 tj-devel709 changed the base branch from release/8.0.1xx-sr9 to release/9.0.1xx October 24, 2024 17:25
@tj-devel709

Copy link
Copy Markdown
Member Author

Okay, test has been rebased off the release/9.0.1xx branch, and it now uses the UIImage as a weakreference instead of the hash. Tests have also been updated on @jsuarezruiz's request!

@tj-devel709

Copy link
Copy Markdown
Member Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines could not run because the pipeline triggers exclude this branch/path.

}
platformButton.UpdateContentEdgeInsets(button, contentEdgeInsets);

_originalImageRef.TryGetTarget(out var _originalImage);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

remove _ from this variable

@PureWeen PureWeen added this to the .NET 9.0 GA milestone Oct 24, 2024

@PureWeen PureWeen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@PureWeen PureWeen merged commit 743afa0 into release/9.0.1xx Oct 25, 2024
@PureWeen PureWeen deleted the dev/TJ/ButtonImageSourceRegression_SR9 branch October 25, 2024 13:11
@PureWeen

Copy link
Copy Markdown
Member

/backport to release/8.0.1xx-sr10

@github-actions

Copy link
Copy Markdown
Contributor

Started backporting to release/8.0.1xx-sr10: https://github.com/dotnet/maui/actions/runs/11518924955

@PureWeen

Copy link
Copy Markdown
Member

/backport to 8.0.1xx-sr9

@github-actions

Copy link
Copy Markdown
Contributor

Started backporting to 8.0.1xx-sr9: https://github.com/dotnet/maui/actions/runs/11595720335

@github-actions

Copy link
Copy Markdown
Contributor

@PureWeen an error occurred while backporting to 8.0.1xx-sr9, please check the run log for details!

The process '/usr/bin/git' failed with exit code 1

PureWeen added a commit that referenced this pull request Oct 30, 2024
Co-authored-by: TJ Lambert <50846373+tj-devel709@users.noreply.github.com>
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 30, 2024
@samhouts samhouts added fixed-in-9.0.0 fixed-in-9.0.10 fixed-in-net8.0-nightly This may be available in a nightly release! labels Dec 16, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants