From 7d711b9ee0f8b6d1b6306b67d2885da9bde625a5 Mon Sep 17 00:00:00 2001 From: Adam Barth Date: Thu, 3 Sep 2015 10:59:26 -0700 Subject: [PATCH] Disable reparent during sync This feature is causing a bug because the widget tree isn't correctly synchronized with the render tree. --- .../flutter/lib/src/widgets/framework.dart | 3 +- packages/unit/test/widget/syncing_test.dart | 67 ++++++++++--------- 2 files changed, 36 insertions(+), 34 deletions(-) diff --git a/packages/flutter/lib/src/widgets/framework.dart b/packages/flutter/lib/src/widgets/framework.dart index bbd125347e5..5f0f2d20942 100644 --- a/packages/flutter/lib/src/widgets/framework.dart +++ b/packages/flutter/lib/src/widgets/framework.dart @@ -19,6 +19,7 @@ export 'package:sky/src/rendering/box.dart' show BoxConstraints, BoxDecoration, export 'package:sky/src/rendering/object.dart' show Point, Offset, Size, Rect, Color, Paint, Path; final bool _shouldLogRenderDuration = false; // see also 'enableProfilingLoop' argument to runApp() +final bool _shouldReparentDuringSync = false; // currently in development typedef Widget Builder(); typedef void WidgetTreeWalker(Widget); @@ -380,7 +381,7 @@ abstract class Widget { Widget candidate = oldNode.singleChild; assert(candidate == null || candidate.parent == oldNode); oldNode = null; - while (candidate != null) { + while (candidate != null && _shouldReparentDuringSync) { if (_canSync(newNode, candidate)) { assert(candidate.parent != null); assert(candidate.parent.singleChild == candidate); diff --git a/packages/unit/test/widget/syncing_test.dart b/packages/unit/test/widget/syncing_test.dart index daef18ebbcf..b478ebc1940 100644 --- a/packages/unit/test/widget/syncing_test.dart +++ b/packages/unit/test/widget/syncing_test.dart @@ -57,38 +57,39 @@ void main() { }); - test('remove one', () { - - WidgetTester tester = new WidgetTester(); - - tester.pumpFrame(() { - return new Container( - child: new Container( - child: new TestState( - state: 10, - child: new Container() - ) - ) - ); - }); - - TestState stateWidget = tester.findWidget((widget) => widget is TestState); - - expect(stateWidget.state, equals(10)); - expect(stateWidget.syncs, equals(0)); - - tester.pumpFrame(() { - return new Container( - child: new TestState( - state: 11, - child: new Container() - ) - ); - }); - - expect(stateWidget.state, equals(10)); - expect(stateWidget.syncs, equals(1)); - - }); + // Requires _shouldReparentDuringSync + // test('remove one', () { + // + // WidgetTester tester = new WidgetTester(); + // + // tester.pumpFrame(() { + // return new Container( + // child: new Container( + // child: new TestState( + // state: 10, + // child: new Container() + // ) + // ) + // ); + // }); + // + // TestState stateWidget = tester.findWidget((widget) => widget is TestState); + // + // expect(stateWidget.state, equals(10)); + // expect(stateWidget.syncs, equals(0)); + // + // tester.pumpFrame(() { + // return new Container( + // child: new TestState( + // state: 11, + // child: new Container() + // ) + // ); + // }); + // + // expect(stateWidget.state, equals(10)); + // expect(stateWidget.syncs, equals(1)); + // + // }); }