fix a RenderBox.size access exception#74402
Merged
Merged
Conversation
chunhtai
reviewed
Jan 21, 2021
| debugDoingThisResize || debugDoingThisLayout || _computingThisDryLayout || | ||
| (RenderObject.debugActiveLayout == parent && _size._canBeUsedByParent), | ||
| (RenderObject.debugActiveLayout == parent && _size._canBeUsedByParent) || | ||
| RenderObject.debugActiveLayout!.debugDoingThisLayoutWithCallback, |
Contributor
There was a problem hiding this comment.
can you move this into the if case in line 1945? This is more like something we want to short-circuit than checking in assert
| buildCount++; | ||
| if (buildCount > 1) { | ||
| final _RenderLayoutSpy spy = tester.renderObject(find.byType(_LayoutSpy)); | ||
| childSize = spy.size; |
Contributor
There was a problem hiding this comment.
what happen if we try to access the size in the first build? we should make sure this situation will throw.
Member
Author
There was a problem hiding this comment.
The RO is null when first build and we can not access size by it.
chunhtai
approved these changes
Jan 22, 2021
chunhtai
left a comment
Contributor
There was a problem hiding this comment.
LGTM, except for indent issue
| ); | ||
| } | ||
| if (RenderObject.debugActiveLayout != null && | ||
| !RenderObject.debugActiveLayout!.debugDoingThisLayoutWithCallback) { |
Member
Author
There was a problem hiding this comment.
Shouldn't it be indented by two spaces?
| if (RenderObject.debugActiveLayout != null && | ||
| !RenderObject.debugActiveLayout!.debugDoingThisLayoutWithCallback) { | ||
| assert( | ||
| debugDoingThisResize || debugDoingThisLayout || _computingThisDryLayout || |
This was referenced Jun 14, 2023
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Why does the exception happen
The
EditableTextStatewill accessRenderBox.sizeduring rebuilding.So, if the
LayoutBuilder.builderreturns aTextFormFieldwidget, it will trigger the exception as follow when_RenderLayoutBuilder.performLayoutis running,I think this type of access is legal and we can use the
RenderObject._doingThisLayoutWithCallbackto distinguish this scenario.Steps to reproduce
See the unit test for details.
Fixes #73676