Make dispose a no-op on HTML backend (flutter/engine#35835)
This commit is contained in:
@@ -260,8 +260,9 @@ class CanvasParagraph implements ui.Paragraph {
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
spans.clear();
|
||||
plainText = '';
|
||||
// TODO(dnfield): It should be possible to clear resources here, but would
|
||||
// need refcounting done on any surfaces/pictures holding references to this
|
||||
// object.
|
||||
_disposed = true;
|
||||
}
|
||||
|
||||
@@ -270,7 +271,7 @@ class CanvasParagraph implements ui.Paragraph {
|
||||
if (assertionsEnabled) {
|
||||
return _disposed;
|
||||
}
|
||||
throw StateError('Vertices.debugDisposed is only avialalbe when asserts are enabled.');
|
||||
throw StateError('Paragraph.debugDisposed is only avialalbe when asserts are enabled.');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -780,6 +780,27 @@ Future<void> testMain() async {
|
||||
expect(paragraph.width, 30);
|
||||
expect(paragraph.height, 10);
|
||||
});
|
||||
|
||||
test('Render after dispose', () {
|
||||
final ui.Paragraph paragraph = plain(ahemStyle, 'abc');
|
||||
paragraph.layout(const ui.ParagraphConstraints(width: 30.8));
|
||||
|
||||
final ui.PictureRecorder recorder = ui.PictureRecorder();
|
||||
final ui.Canvas canvas = ui.Canvas(recorder);
|
||||
canvas.drawParagraph(paragraph, ui.Offset.zero);
|
||||
final ui.Picture picture = recorder.endRecording();
|
||||
|
||||
paragraph.dispose();
|
||||
|
||||
final ui.SceneBuilder builder = ui.SceneBuilder();
|
||||
builder.addPicture(ui.Offset.zero, picture);
|
||||
final ui.Scene scene = builder.build();
|
||||
|
||||
ui.window.render(scene);
|
||||
|
||||
picture.dispose();
|
||||
scene.dispose();
|
||||
});
|
||||
}
|
||||
|
||||
/// Shortcut to create a [ui.TextBox] with an optional [ui.TextDirection].
|
||||
|
||||
Reference in New Issue
Block a user