Make dispose a no-op on HTML backend (flutter/engine#35835)

This commit is contained in:
Dan Field
2022-08-31 15:57:07 -07:00
committed by GitHub
parent d42ff66054
commit 69c3834e4c
2 changed files with 25 additions and 3 deletions

View File

@@ -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.');
}
}

View File

@@ -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].