Skip to content
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

InheritedElement.removeDependent() #129210

Merged
merged 1 commit into from
Nov 3, 2023
Merged

Conversation

s0nerik
Copy link
Contributor

@s0nerik s0nerik commented Jun 20, 2023

Call the dependency.removeDependent(this) instead of dependency._dependents.remove(this) inside the Element.deactivate(). This allows InheritedElements to know when they can release resources associated with a given dependent Element.

Fixes #129207

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I signed the CLA.
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is test-exempt.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@github-actions github-actions bot added the framework flutter/packages/flutter repository. See also f: labels. label Jun 20, 2023
@goderbauer goderbauer self-requested a review June 20, 2023 22:10
@flutter-dashboard
Copy link

It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat (don't just cc him here, he won't see it! He's on Discord!).

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

@s0nerik
Copy link
Contributor Author

s0nerik commented Jun 23, 2023

@goderbauer I've added the test. Please take a look.

@goderbauer
Copy link
Member

There's a lengthy discussion about exactly this API in #128432, which hasn't reached a conclusion yet and we should hold off on this change until it does. I would encourage you to post your use case there as that seems to be what's still missing: a compelling argument for actually having this API.

@s0nerik
Copy link
Contributor Author

s0nerik commented Jul 7, 2023

I already have a slightly adjusted version of this PR that actually solves #128432. @goderbauer please let me know if I should create a new PR for that or just push these changes into this one and adjust the description a bit.

@goderbauer
Copy link
Member

@s0nerik I lost track of this PR and I apologize for the delay. If we actually decide to do this, I would prefer the approach that was outlined in the first few comments of #128432 (i.e. introduce a removeDependency method to complete the existing set of update, get, set methods) instead of adding a separate notification mechanism as implemented in this PR. Is that the change you had in mind with your previous comment? Would you mind pushing that into this PR so we can evaluate that?

@s0nerik s0nerik changed the title Notify InheritedElement when dependent is removed InheritedElement.removeDependent() Oct 7, 2023
@s0nerik
Copy link
Contributor Author

s0nerik commented Oct 7, 2023

Hey @goderbauer, thanks for reaching out. I've pushed the changes I mentioned before along with some doc comment adjustments for clarity.

BTW, I named the method removeDependent, not removeDependency since it makes much more sense to me that way as it is defined on an InheritedElement and is supposed to remove another Element from the list of dependents of this InheritedElement.

Copy link
Member

@goderbauer goderbauer left a comment

Choose a reason for hiding this comment

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

LGTM after doc nit is resolved.

packages/flutter/lib/src/widgets/framework.dart Outdated Show resolved Hide resolved
@goderbauer
Copy link
Member

@s0nerik Can you rebase this with the latest master to make the checks happy?

@s0nerik s0nerik force-pushed the patch-1 branch 3 times, most recently from b36952b to d9ed570 Compare November 3, 2023 08:42
@s0nerik
Copy link
Contributor Author

s0nerik commented Nov 3, 2023

@goderbauer All checks seem to be happy now.

Copy link
Member

@goderbauer goderbauer left a comment

Choose a reason for hiding this comment

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

LGTM

engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 4, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 5, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 5, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 6, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 6, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 6, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 6, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 6, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Nov 6, 2023
auto-submit bot pushed a commit to flutter/packages that referenced this pull request Nov 6, 2023
Roll Flutter from 29b2516 to f5a9835 (101 revisions)

flutter/flutter@29b2516...f5a9835

2023-11-06 [email protected] Check sample links for malformed links (flutter/flutter#137807)
2023-11-06 [email protected] Change cast in json parsing (flutter/flutter#137708)
2023-11-06 98614782+auto-submit[bot]@users.noreply.github.com Reverts "Update BottomNavigationBar tests for M3" (flutter/flutter#137948)
2023-11-06 [email protected] Roll Packages from cccf5d2 to 49eac1f (2 revisions) (flutter/flutter#137943)
2023-11-06 [email protected] Update BottomNavigationBar tests for M3 (flutter/flutter#136624)
2023-11-06 [email protected] Roll Flutter Engine from 4f6ed31bd8bd to bdfa8aa8f81f (1 revision) (flutter/flutter#137941)
2023-11-06 [email protected] Roll Flutter Engine from b9b3269b0b2c to 4f6ed31bd8bd (2 revisions) (flutter/flutter#137935)
2023-11-06 [email protected] Provide a helpful error message when `ColorScheme.brightness` doesn't match `ThemeData.brightness` (flutter/flutter#137611)
2023-11-06 [email protected] Roll Flutter Engine from 555ffa17b55c to b9b3269b0b2c (1 revision) (flutter/flutter#137933)
2023-11-06 [email protected] Fix tool exit message shown when user provides a non-list to "assets" for a deferred component (flutter/flutter#137837)
2023-11-06 [email protected] Roll Flutter Engine from 0d8c7ceacc01 to 555ffa17b55c (1 revision) (flutter/flutter#137921)
2023-11-06 [email protected] Roll Flutter Engine from 11d66db97d3f to 0d8c7ceacc01 (1 revision) (flutter/flutter#137920)
2023-11-05 [email protected] Roll Flutter Engine from a7592e42464c to 11d66db97d3f (1 revision) (flutter/flutter#137914)
2023-11-05 [email protected] Roll Flutter Engine from 1c6bd97e2288 to a7592e42464c (1 revision) (flutter/flutter#137912)
2023-11-05 [email protected] Roll Flutter Engine from daf18fe46b72 to 1c6bd97e2288 (1 revision) (flutter/flutter#137908)
2023-11-04 [email protected] Roll Flutter Engine from a45e679828e6 to daf18fe46b72 (1 revision) (flutter/flutter#137904)
2023-11-04 [email protected] Roll Flutter Engine from fb2a9c20141e to a45e679828e6 (1 revision) (flutter/flutter#137903)
2023-11-04 [email protected] Roll Flutter Engine from 576833873c15 to fb2a9c20141e (1 revision) (flutter/flutter#137900)
2023-11-04 [email protected] Roll Flutter Engine from 25f5e285f874 to 576833873c15 (1 revision) (flutter/flutter#137898)
2023-11-04 [email protected] Roll Flutter Engine from 7282a5d94ab6 to 25f5e285f874 (2 revisions) (flutter/flutter#137892)
2023-11-04 [email protected] Roll Flutter Engine from b66a87626300 to 7282a5d94ab6 (2 revisions) (flutter/flutter#137887)
2023-11-04 [email protected] HeroController should dispatch creation and disposal events. (flutter/flutter#137835)
2023-11-04 [email protected] Roll Flutter Engine from ec20731de6ff to b66a87626300 (1 revision) (flutter/flutter#137877)
2023-11-03 [email protected] InheritedElement.removeDependent() (flutter/flutter#129210)
2023-11-03 [email protected] Remove unused generic type from BottomSheet (flutter/flutter#137791)
2023-11-03 [email protected] Roll Flutter Engine from 035740c1f90e to ec20731de6ff (2 revisions) (flutter/flutter#137872)
2023-11-03 [email protected] Pin dart-lang/native dependencies (flutter/flutter#137601)
2023-11-03 [email protected] Send caret rect to embedder on selection update (flutter/flutter#137863)
2023-11-03 [email protected] Roll Flutter Engine from 677040f10f65 to 035740c1f90e (4 revisions) (flutter/flutter#137871)
2023-11-03 [email protected] Tooltip docs: Recommend setting preferBelow to false in theme (flutter/flutter#135879)
2023-11-03 [email protected] Roll Flutter Engine from f363a6e5e093 to 677040f10f65 (2 revisions) (flutter/flutter#137861)
2023-11-03 98614782+auto-submit[bot]@users.noreply.github.com Reverts "[Android] Support Android 34" (flutter/flutter#137865)
2023-11-03 [email protected] InkFeature should dispatch creation and disposal events. (flutter/flutter#137793)
2023-11-03 [email protected] AppLifecycleListener should dispatch creation and disposal events. (flutter/flutter#137840)
2023-11-03 [email protected] Roll Flutter Engine from d5ccb5b1b706 to f363a6e5e093 (2 revisions) (flutter/flutter#137858)
2023-11-03 [email protected] Roll Flutter Engine from 72262a238090 to d5ccb5b1b706 (3 revisions) (flutter/flutter#137857)
2023-11-03 [email protected] Updated the nested navigation NavigationBar example (flutter/flutter#137788)
2023-11-03 [email protected] Roll Flutter Engine from 0415a4f5e2a2 to 72262a238090 (2 revisions) (flutter/flutter#137853)
2023-11-03 [email protected] Roll Flutter Engine from 8531c5935356 to 0415a4f5e2a2 (1 revision) (flutter/flutter#137847)
2023-11-03 [email protected] Roll flutter gallery version forward. (flutter/flutter#137846)
2023-11-03 [email protected] Roll Flutter Engine from 43653c5a3ec8 to 8531c5935356 (1 revision) (flutter/flutter#137845)
2023-11-03 [email protected] Roll Packages from 33c2b4e to cccf5d2 (6 revisions) (flutter/flutter#137841)
2023-11-03 [email protected] [web] dispatch corresponding keyup events in text editing integrations (flutter/flutter#136874)
2023-11-03 [email protected] [leak-tracking] Add more leak tracking in test/painting #3 (flutter/flutter#136170)
2023-11-03 [email protected] Upgrade leak_tracker and remove some deps in allow list. (flutter/flutter#137806)
2023-11-03 [email protected] Roll Flutter Engine from fc7c3f70c076 to 43653c5a3ec8 (1 revision) (flutter/flutter#137827)
...
HugoOlthof pushed a commit to moneybird/packages that referenced this pull request Dec 13, 2023
Roll Flutter from 29b2516 to f5a9835 (101 revisions)

flutter/flutter@29b2516...f5a9835

2023-11-06 [email protected] Check sample links for malformed links (flutter/flutter#137807)
2023-11-06 [email protected] Change cast in json parsing (flutter/flutter#137708)
2023-11-06 98614782+auto-submit[bot]@users.noreply.github.com Reverts "Update BottomNavigationBar tests for M3" (flutter/flutter#137948)
2023-11-06 [email protected] Roll Packages from cccf5d2 to 49eac1f (2 revisions) (flutter/flutter#137943)
2023-11-06 [email protected] Update BottomNavigationBar tests for M3 (flutter/flutter#136624)
2023-11-06 [email protected] Roll Flutter Engine from 4f6ed31bd8bd to bdfa8aa8f81f (1 revision) (flutter/flutter#137941)
2023-11-06 [email protected] Roll Flutter Engine from b9b3269b0b2c to 4f6ed31bd8bd (2 revisions) (flutter/flutter#137935)
2023-11-06 [email protected] Provide a helpful error message when `ColorScheme.brightness` doesn't match `ThemeData.brightness` (flutter/flutter#137611)
2023-11-06 [email protected] Roll Flutter Engine from 555ffa17b55c to b9b3269b0b2c (1 revision) (flutter/flutter#137933)
2023-11-06 [email protected] Fix tool exit message shown when user provides a non-list to "assets" for a deferred component (flutter/flutter#137837)
2023-11-06 [email protected] Roll Flutter Engine from 0d8c7ceacc01 to 555ffa17b55c (1 revision) (flutter/flutter#137921)
2023-11-06 [email protected] Roll Flutter Engine from 11d66db97d3f to 0d8c7ceacc01 (1 revision) (flutter/flutter#137920)
2023-11-05 [email protected] Roll Flutter Engine from a7592e42464c to 11d66db97d3f (1 revision) (flutter/flutter#137914)
2023-11-05 [email protected] Roll Flutter Engine from 1c6bd97e2288 to a7592e42464c (1 revision) (flutter/flutter#137912)
2023-11-05 [email protected] Roll Flutter Engine from daf18fe46b72 to 1c6bd97e2288 (1 revision) (flutter/flutter#137908)
2023-11-04 [email protected] Roll Flutter Engine from a45e679828e6 to daf18fe46b72 (1 revision) (flutter/flutter#137904)
2023-11-04 [email protected] Roll Flutter Engine from fb2a9c20141e to a45e679828e6 (1 revision) (flutter/flutter#137903)
2023-11-04 [email protected] Roll Flutter Engine from 576833873c15 to fb2a9c20141e (1 revision) (flutter/flutter#137900)
2023-11-04 [email protected] Roll Flutter Engine from 25f5e285f874 to 576833873c15 (1 revision) (flutter/flutter#137898)
2023-11-04 [email protected] Roll Flutter Engine from 7282a5d94ab6 to 25f5e285f874 (2 revisions) (flutter/flutter#137892)
2023-11-04 [email protected] Roll Flutter Engine from b66a87626300 to 7282a5d94ab6 (2 revisions) (flutter/flutter#137887)
2023-11-04 [email protected] HeroController should dispatch creation and disposal events. (flutter/flutter#137835)
2023-11-04 [email protected] Roll Flutter Engine from ec20731de6ff to b66a87626300 (1 revision) (flutter/flutter#137877)
2023-11-03 [email protected] InheritedElement.removeDependent() (flutter/flutter#129210)
2023-11-03 [email protected] Remove unused generic type from BottomSheet (flutter/flutter#137791)
2023-11-03 [email protected] Roll Flutter Engine from 035740c1f90e to ec20731de6ff (2 revisions) (flutter/flutter#137872)
2023-11-03 [email protected] Pin dart-lang/native dependencies (flutter/flutter#137601)
2023-11-03 [email protected] Send caret rect to embedder on selection update (flutter/flutter#137863)
2023-11-03 [email protected] Roll Flutter Engine from 677040f10f65 to 035740c1f90e (4 revisions) (flutter/flutter#137871)
2023-11-03 [email protected] Tooltip docs: Recommend setting preferBelow to false in theme (flutter/flutter#135879)
2023-11-03 [email protected] Roll Flutter Engine from f363a6e5e093 to 677040f10f65 (2 revisions) (flutter/flutter#137861)
2023-11-03 98614782+auto-submit[bot]@users.noreply.github.com Reverts "[Android] Support Android 34" (flutter/flutter#137865)
2023-11-03 [email protected] InkFeature should dispatch creation and disposal events. (flutter/flutter#137793)
2023-11-03 [email protected] AppLifecycleListener should dispatch creation and disposal events. (flutter/flutter#137840)
2023-11-03 [email protected] Roll Flutter Engine from d5ccb5b1b706 to f363a6e5e093 (2 revisions) (flutter/flutter#137858)
2023-11-03 [email protected] Roll Flutter Engine from 72262a238090 to d5ccb5b1b706 (3 revisions) (flutter/flutter#137857)
2023-11-03 [email protected] Updated the nested navigation NavigationBar example (flutter/flutter#137788)
2023-11-03 [email protected] Roll Flutter Engine from 0415a4f5e2a2 to 72262a238090 (2 revisions) (flutter/flutter#137853)
2023-11-03 [email protected] Roll Flutter Engine from 8531c5935356 to 0415a4f5e2a2 (1 revision) (flutter/flutter#137847)
2023-11-03 [email protected] Roll flutter gallery version forward. (flutter/flutter#137846)
2023-11-03 [email protected] Roll Flutter Engine from 43653c5a3ec8 to 8531c5935356 (1 revision) (flutter/flutter#137845)
2023-11-03 [email protected] Roll Packages from 33c2b4e to cccf5d2 (6 revisions) (flutter/flutter#137841)
2023-11-03 [email protected] [web] dispatch corresponding keyup events in text editing integrations (flutter/flutter#136874)
2023-11-03 [email protected] [leak-tracking] Add more leak tracking in test/painting flutter#3 (flutter/flutter#136170)
2023-11-03 [email protected] Upgrade leak_tracker and remove some deps in allow list. (flutter/flutter#137806)
2023-11-03 [email protected] Roll Flutter Engine from fc7c3f70c076 to 43653c5a3ec8 (1 revision) (flutter/flutter#137827)
...
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
autosubmit Merge PR when tree becomes green via auto submit App framework flutter/packages/flutter repository. See also f: labels.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

There's no way for InheritedElement to know that a dependent has been deactivated
3 participants