mirror of
https://github.com/flutter/flutter
synced 2024-10-13 19:52:53 +00:00
Wrap _debug flag setting in asserts. (#13974)
Fixes the last bits of #5759.
This commit is contained in:
parent
3905d99109
commit
7cf58702c1
|
@ -700,8 +700,13 @@ class PipelineOwner {
|
||||||
///
|
///
|
||||||
/// See [RendererBinding] for an example of how this function is used.
|
/// See [RendererBinding] for an example of how this function is used.
|
||||||
void flushLayout() {
|
void flushLayout() {
|
||||||
Timeline.startSync('Layout', arguments: timelineWhitelistArguments);
|
profile(() {
|
||||||
_debugDoingLayout = true;
|
Timeline.startSync('Layout', arguments: timelineWhitelistArguments);
|
||||||
|
});
|
||||||
|
assert(() {
|
||||||
|
_debugDoingLayout = true;
|
||||||
|
return true;
|
||||||
|
}());
|
||||||
try {
|
try {
|
||||||
// TODO(ianh): assert that we're not allowing previously dirty nodes to redirty themselves
|
// TODO(ianh): assert that we're not allowing previously dirty nodes to redirty themselves
|
||||||
while (_nodesNeedingLayout.isNotEmpty) {
|
while (_nodesNeedingLayout.isNotEmpty) {
|
||||||
|
@ -713,8 +718,13 @@ class PipelineOwner {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
_debugDoingLayout = false;
|
assert(() {
|
||||||
Timeline.finishSync();
|
_debugDoingLayout = false;
|
||||||
|
return true;
|
||||||
|
}());
|
||||||
|
profile(() {
|
||||||
|
Timeline.finishSync();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -728,12 +738,19 @@ class PipelineOwner {
|
||||||
// See [RenderObject.invokeLayoutCallback].
|
// See [RenderObject.invokeLayoutCallback].
|
||||||
void _enableMutationsToDirtySubtrees(VoidCallback callback) {
|
void _enableMutationsToDirtySubtrees(VoidCallback callback) {
|
||||||
assert(_debugDoingLayout);
|
assert(_debugDoingLayout);
|
||||||
final bool oldState = _debugAllowMutationsToDirtySubtrees;
|
bool oldState;
|
||||||
_debugAllowMutationsToDirtySubtrees = true;
|
assert(() {
|
||||||
|
oldState = _debugAllowMutationsToDirtySubtrees;
|
||||||
|
_debugAllowMutationsToDirtySubtrees = true;
|
||||||
|
return true;
|
||||||
|
}());
|
||||||
try {
|
try {
|
||||||
callback();
|
callback();
|
||||||
} finally {
|
} finally {
|
||||||
_debugAllowMutationsToDirtySubtrees = oldState;
|
assert(() {
|
||||||
|
_debugAllowMutationsToDirtySubtrees = oldState;
|
||||||
|
return true;
|
||||||
|
}());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -743,14 +760,14 @@ class PipelineOwner {
|
||||||
/// Called as part of the rendering pipeline after [flushLayout] and before
|
/// Called as part of the rendering pipeline after [flushLayout] and before
|
||||||
/// [flushPaint].
|
/// [flushPaint].
|
||||||
void flushCompositingBits() {
|
void flushCompositingBits() {
|
||||||
Timeline.startSync('Compositing bits');
|
profile(() { Timeline.startSync('Compositing bits'); });
|
||||||
_nodesNeedingCompositingBitsUpdate.sort((RenderObject a, RenderObject b) => a.depth - b.depth);
|
_nodesNeedingCompositingBitsUpdate.sort((RenderObject a, RenderObject b) => a.depth - b.depth);
|
||||||
for (RenderObject node in _nodesNeedingCompositingBitsUpdate) {
|
for (RenderObject node in _nodesNeedingCompositingBitsUpdate) {
|
||||||
if (node._needsCompositingBitsUpdate && node.owner == this)
|
if (node._needsCompositingBitsUpdate && node.owner == this)
|
||||||
node._updateCompositingBits();
|
node._updateCompositingBits();
|
||||||
}
|
}
|
||||||
_nodesNeedingCompositingBitsUpdate.clear();
|
_nodesNeedingCompositingBitsUpdate.clear();
|
||||||
Timeline.finishSync();
|
profile(() { Timeline.finishSync(); });
|
||||||
}
|
}
|
||||||
|
|
||||||
List<RenderObject> _nodesNeedingPaint = <RenderObject>[];
|
List<RenderObject> _nodesNeedingPaint = <RenderObject>[];
|
||||||
|
@ -771,8 +788,11 @@ class PipelineOwner {
|
||||||
///
|
///
|
||||||
/// See [RendererBinding] for an example of how this function is used.
|
/// See [RendererBinding] for an example of how this function is used.
|
||||||
void flushPaint() {
|
void flushPaint() {
|
||||||
Timeline.startSync('Paint', arguments: timelineWhitelistArguments);
|
profile(() { Timeline.startSync('Paint', arguments: timelineWhitelistArguments); });
|
||||||
_debugDoingPaint = true;
|
assert(() {
|
||||||
|
_debugDoingPaint = true;
|
||||||
|
return true;
|
||||||
|
}());
|
||||||
try {
|
try {
|
||||||
final List<RenderObject> dirtyNodes = _nodesNeedingPaint;
|
final List<RenderObject> dirtyNodes = _nodesNeedingPaint;
|
||||||
_nodesNeedingPaint = <RenderObject>[];
|
_nodesNeedingPaint = <RenderObject>[];
|
||||||
|
@ -789,8 +809,11 @@ class PipelineOwner {
|
||||||
}
|
}
|
||||||
assert(_nodesNeedingPaint.isEmpty);
|
assert(_nodesNeedingPaint.isEmpty);
|
||||||
} finally {
|
} finally {
|
||||||
_debugDoingPaint = false;
|
assert(() {
|
||||||
Timeline.finishSync();
|
_debugDoingPaint = false;
|
||||||
|
return true;
|
||||||
|
}());
|
||||||
|
profile(() { Timeline.finishSync(); });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -860,7 +883,7 @@ class PipelineOwner {
|
||||||
void flushSemantics() {
|
void flushSemantics() {
|
||||||
if (_semanticsOwner == null)
|
if (_semanticsOwner == null)
|
||||||
return;
|
return;
|
||||||
Timeline.startSync('Semantics');
|
profile(() { Timeline.startSync('Semantics'); });
|
||||||
assert(_semanticsOwner != null);
|
assert(_semanticsOwner != null);
|
||||||
assert(() { _debugDoingSemantics = true; return true; }());
|
assert(() { _debugDoingSemantics = true; return true; }());
|
||||||
try {
|
try {
|
||||||
|
@ -875,7 +898,7 @@ class PipelineOwner {
|
||||||
} finally {
|
} finally {
|
||||||
assert(_nodesNeedingSemantics.isEmpty);
|
assert(_nodesNeedingSemantics.isEmpty);
|
||||||
assert(() { _debugDoingSemantics = false; return true; }());
|
assert(() { _debugDoingSemantics = false; return true; }());
|
||||||
Timeline.finishSync();
|
profile(() { Timeline.finishSync(); });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2452,16 +2475,21 @@ abstract class RenderObject extends AbstractNode with DiagnosticableTreeMixin im
|
||||||
String prefixOtherLines: '',
|
String prefixOtherLines: '',
|
||||||
DiagnosticLevel minLevel: DiagnosticLevel.debug,
|
DiagnosticLevel minLevel: DiagnosticLevel.debug,
|
||||||
}) {
|
}) {
|
||||||
final RenderObject debugPreviousActiveLayout = _debugActiveLayout;
|
RenderObject debugPreviousActiveLayout;
|
||||||
_debugActiveLayout = null;
|
assert(() {
|
||||||
|
debugPreviousActiveLayout = _debugActiveLayout;
|
||||||
|
_debugActiveLayout = null;
|
||||||
|
return true;
|
||||||
|
}());
|
||||||
final String result = super.toStringDeep(
|
final String result = super.toStringDeep(
|
||||||
prefixLineOne: prefixLineOne,
|
prefixLineOne: prefixLineOne,
|
||||||
prefixOtherLines: prefixOtherLines,
|
prefixOtherLines: prefixOtherLines,
|
||||||
minLevel: minLevel,
|
minLevel: minLevel,
|
||||||
);
|
);
|
||||||
|
assert(() {
|
||||||
_debugActiveLayout = debugPreviousActiveLayout;
|
_debugActiveLayout = debugPreviousActiveLayout;
|
||||||
|
return true;
|
||||||
|
}());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2475,10 +2503,17 @@ abstract class RenderObject extends AbstractNode with DiagnosticableTreeMixin im
|
||||||
String joiner: '; ',
|
String joiner: '; ',
|
||||||
DiagnosticLevel minLevel: DiagnosticLevel.debug,
|
DiagnosticLevel minLevel: DiagnosticLevel.debug,
|
||||||
}) {
|
}) {
|
||||||
final RenderObject debugPreviousActiveLayout = _debugActiveLayout;
|
RenderObject debugPreviousActiveLayout;
|
||||||
_debugActiveLayout = null;
|
assert(() {
|
||||||
|
debugPreviousActiveLayout = _debugActiveLayout;
|
||||||
|
_debugActiveLayout = null;
|
||||||
|
return true;
|
||||||
|
}());
|
||||||
final String result = super.toStringShallow(joiner: joiner, minLevel: minLevel);
|
final String result = super.toStringShallow(joiner: joiner, minLevel: minLevel);
|
||||||
_debugActiveLayout = debugPreviousActiveLayout;
|
assert(() {
|
||||||
|
_debugActiveLayout = debugPreviousActiveLayout;
|
||||||
|
return true;
|
||||||
|
}());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue