-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Fix Button Regression with null image source #25485
Fix Button Regression with null image source #25485
Conversation
#if IOS | ||
((Action)(async () => | ||
{ | ||
var imageSource = new FileImageSource() { File = "shopping_cart.png" }; |
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.
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).
?
e8b6993
to
7807d75
Compare
7807d75
to
cc5dc08
Compare
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! |
/azp run |
Azure Pipelines could not run because the pipeline triggers exclude this branch/path. |
@@ -81,22 +80,29 @@ Size ICrossPlatformLayout.CrossPlatformMeasure(double widthConstraint, double he | |||
} | |||
platformButton.UpdateContentEdgeInsets(button, contentEdgeInsets); | |||
|
|||
_originalImageRef.TryGetTarget(out var _originalImage); |
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.
remove _ from this variable
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.
/backport to release/8.0.1xx-sr10 |
Started backporting to release/8.0.1xx-sr10: https://github.com/dotnet/maui/actions/runs/11518924955 |
/backport to 8.0.1xx-sr9 |
Started backporting to 8.0.1xx-sr9: https://github.com/dotnet/maui/actions/runs/11595720335 |
@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 |
Co-authored-by: TJ Lambert <[email protected]>
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