fix null access for CkParagraph.dispose (flutter/engine#35815)

This commit is contained in:
Dan Field
2022-08-31 08:47:58 -07:00
committed by GitHub
parent 95ac57a5a9
commit 92b5870e75
2 changed files with 14 additions and 1 deletions

View File

@@ -657,7 +657,8 @@ class CkParagraph extends SkiaObject<SkParagraph> implements ui.Paragraph {
@override
void delete() {
_skParagraph!.delete();
_skParagraph?.delete();
_skParagraph = null;
}
@override

View File

@@ -1342,6 +1342,18 @@ void _canvasTests() {
);
});
test('Paragraph dispose', () {
final CkParagraphBuilder builder = CkParagraphBuilder(
CkParagraphStyle(),
);
builder.addText('Hello');
final CkParagraph paragraph = builder.build();
paragraph.delete();
paragraph.dispose();
expect(paragraph.debugDisposed, true);
});
test('toImage.toByteData', () async {
// Pretend that FinalizationRegistry is supported, so we can run this
// test in older browsers (the test will use a TestCollector instead of