Reset ParagraphBuilder after build() (flutter/engine#7401)

* Reset ParagraphBuilder after build()
This commit is contained in:
Dan Field
2019-01-07 16:10:53 -08:00
committed by GitHub
parent 4649c4b09d
commit df35434ca0
2 changed files with 8 additions and 0 deletions

View File

@@ -17,4 +17,11 @@ void main() {
expect(paragraph.width, isNonZero);
expect(paragraph.height, isNonZero);
});
test('PushStyle should not segfault after build()', () {
final ParagraphBuilder paragraphBuilder =
ParagraphBuilder(ParagraphStyle());
paragraphBuilder.build();
paragraphBuilder.pushStyle(TextStyle());
});
}

View File

@@ -84,6 +84,7 @@ std::unique_ptr<Paragraph> ParagraphBuilder::Build() {
paragraph->SetText(std::move(text_), std::move(runs_));
paragraph->SetParagraphStyle(paragraph_style_);
paragraph->SetFontCollection(font_collection_);
SetParagraphStyle(paragraph_style_);
return paragraph;
}