-
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
[ios] fix memory leak in SearchBar #16383
Merged
Merged
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
b3eb860
[ios] fix memory leak in SearchBar
jonathanpeppers f8219bf
Restore some changes, `_editor` field
jonathanpeppers 639d42c
Code cleanup
jonathanpeppers eda250a
Merge branch 'main' into SearchBarLeaks
jonathanpeppers f887e99
Call updateText in OnEditingChanged
tj-devel709 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,9 +10,25 @@ public static class SearchBarExtensions | |
internal static UITextField? GetSearchTextField(this UISearchBar searchBar) | ||
{ | ||
if (OperatingSystem.IsIOSVersionAtLeast(13)) | ||
{ | ||
return searchBar.SearchTextField; | ||
else | ||
return searchBar.GetSearchTextField(); | ||
} | ||
Comment on lines
12
to
+15
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If iOS < 13 before, this just threw |
||
|
||
// Search Subviews up to two levels deep | ||
// https://stackoverflow.com/a/58056700 | ||
foreach (var child in searchBar.Subviews) | ||
{ | ||
if (child is UITextField childTextField) | ||
return childTextField; | ||
|
||
foreach (var grandChild in child.Subviews) | ||
{ | ||
if (grandChild is UITextField grandChildTextField) | ||
return grandChildTextField; | ||
} | ||
} | ||
|
||
return null; | ||
} | ||
|
||
internal static void UpdateBackground(this UISearchBar uiSearchBar, ISearchBar searchBar) | ||
|
Oops, something went wrong.
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.
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.
LGTM.
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.
This PR completely breaks all the UI tests, which accesses a
SearchBar
to find & run each test?I did not figure out the cause, it seemed like
SearchBar
generally worked when I tried in other apps like the DeviceTests.