Remove bogus code in ContainerParentDataMixin.detach (#37479)

This commit is contained in:
Michael Goderbauer 2019-08-07 09:22:51 -07:00 committed by GitHub
parent 39a04dcd7f
commit 4cf1a3504b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 14 deletions

View File

@ -2834,21 +2834,9 @@ mixin ContainerParentDataMixin<ChildType extends RenderObject> on ParentData {
/// Clear the sibling pointers.
@override
void detach() {
assert(previousSibling == null, 'Pointers to siblings must be nulled before detaching ParentData.');
assert(nextSibling == null, 'Pointers to siblings must be nulled before detaching ParentData.');
super.detach();
if (previousSibling != null) {
final ContainerParentDataMixin<ChildType> previousSiblingParentData = previousSibling.parentData;
assert(previousSibling != this);
assert(previousSiblingParentData.nextSibling == this);
previousSiblingParentData.nextSibling = nextSibling;
}
if (nextSibling != null) {
final ContainerParentDataMixin<ChildType> nextSiblingParentData = nextSibling.parentData;
assert(nextSibling != this);
assert(nextSiblingParentData.previousSibling == this);
nextSiblingParentData.previousSibling = previousSibling;
}
previousSibling = null;
nextSibling = null;
}
}

View File

@ -81,8 +81,27 @@ void main() {
),
);
});
test('ContainerParentDataMixin requires nulled out pointers to siblings before detach', () {
expect(() => TestParentData().detach(), isNot(throwsAssertionError));
final TestParentData data1 = TestParentData()
..nextSibling = RenderOpacity()
..previousSibling = RenderOpacity();
expect(() => data1.detach(), throwsAssertionError);
final TestParentData data2 = TestParentData()
..previousSibling = RenderOpacity();
expect(() => data2.detach(), throwsAssertionError);
final TestParentData data3 = TestParentData()
..nextSibling = RenderOpacity();
expect(() => data3.detach(), throwsAssertionError);
});
}
class TestParentData extends ParentData with ContainerParentDataMixin<RenderBox> { }
class TestRenderObject extends RenderObject {
@override
void debugAssertDoesMeetConstraints() { }