Skip to content

Conversation

@gnprice
Copy link
Member

@gnprice gnprice commented Jul 16, 2023

Fixes #115525.

On [AbstractNode.detach] and its two progeny [RenderNode.detach]
and [Layer.detach], the docs said both to call the inherited method
before detaching children, and to end by doing so. The former
advice is what's enforced by an assertion in the base implementation,
so cut out the other.

The corresponding [attach] methods redundantly said twice to
call the inherited method first, so cut the redundancy.
Leave in place the version more recently added (in #76021), because
that PR shows the old version must have been easy to overlook.

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.

Fixes flutter#115525.

On [AbstractNode.detach] and its two progeny [RenderNode.detach]
and [Layer.detach], the docs said both to call the inherited method
before detaching children, and to end by doing so.  The former
advice is what's enforced by an assertion in the base implementation,
so cut out the other.

The corresponding [attach] methods redundantly said twice to
call the inherited method first, so cut the redundancy.
Leave in place the version more recently added (in flutter#76021), because
that PR shows the old version must have been easy to overlook.
@github-actions github-actions bot added the framework flutter/packages/flutter repository. See also f: labels. label Jul 16, 2023
@Hixie
Copy link
Contributor

Hixie commented Jul 17, 2023

Would it make sense to phrase it something like "Implementations in subclasses should attach their children after calling the superclass method" (as opposed to "must start with calling the superclass method")? (Maybe with better phrasing, that's not my best work!) The point being to avoid implying that doing unrelated work before calling the superclass is a problem.

@gnprice
Copy link
Member Author

gnprice commented Jul 17, 2023

Yeah. Perhaps like this?

  /// Subclasses with children should override this method to
  /// [attach] all their children to the same [owner]
  /// after calling the inherited method, as in `super.attach(owner)`.
  /// Subclasses with children should override this method to
  /// [detach] all their children after calling the inherited
  /// method, as in `super.detach()`.

That is:

  • Subclasses with children should override this method. (Other subclasses may or may not need to.)
  • Specifically, they should attach/detach all their children.
  • They should do that after the super call (but the ordering vs. any other work is unspecified).

This version (unlike what's in main) doesn't mention that implementations even in subclasses without children should call the superclass method. But @mustCallSuper means the linter will cover that, so that seems OK.

@Hixie
Copy link
Contributor

Hixie commented Jul 17, 2023

SGTM.

@gnprice
Copy link
Member Author

gnprice commented Jul 17, 2023

Cool. Pushed a revision with that text.

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

@gnprice gnprice added the autosubmit Merge PR when tree becomes green via auto submit App label Jul 18, 2023
@auto-submit auto-submit bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Jul 19, 2023
@auto-submit
Copy link
Contributor

auto-submit bot commented Jul 19, 2023

auto label is removed for flutter/flutter, pr: 130688, due to - The status or check suite Google testing has failed. Please fix the issues identified (or deflake) before re-applying this label.

@goderbauer goderbauer added the autosubmit Merge PR when tree becomes green via auto submit App label Jul 19, 2023
@auto-submit auto-submit bot merged commit f003911 into flutter:master Jul 19, 2023
@gnprice gnprice deleted the pr-detach-doc branch July 19, 2023 18:50
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 20, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 20, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 20, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 21, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 21, 2023
LouiseHsu pushed a commit to LouiseHsu/flutter that referenced this pull request Jul 31, 2023
…flutter#130688)

Fixes flutter#115525.

On [AbstractNode.detach] and its two progeny [RenderNode.detach]
and [Layer.detach], the docs said both to call the inherited method
before detaching children, and to end by doing so.  The former
advice is what's enforced by an assertion in the base implementation,
so cut out the other.

The corresponding [attach] methods redundantly said twice to
call the inherited method first, so cut the redundancy.
Leave in place the version more recently added (in flutter#76021), because
that PR shows the old version must have been easy to overlook.
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.

Conflicting API docs for RenderObjects

3 participants