From df35434ca03f6b1ba1500b811fe4305295966016 Mon Sep 17 00:00:00 2001 From: Dan Field Date: Mon, 7 Jan 2019 16:10:53 -0800 Subject: [PATCH] Reset ParagraphBuilder after build() (flutter/engine#7401) * Reset ParagraphBuilder after build() --- .../src/flutter/testing/dart/paragraph_builder_test.dart | 7 +++++++ .../flutter/third_party/txt/src/txt/paragraph_builder.cc | 1 + 2 files changed, 8 insertions(+) diff --git a/engine/src/flutter/testing/dart/paragraph_builder_test.dart b/engine/src/flutter/testing/dart/paragraph_builder_test.dart index 0743825f8e..d84a8e17c5 100644 --- a/engine/src/flutter/testing/dart/paragraph_builder_test.dart +++ b/engine/src/flutter/testing/dart/paragraph_builder_test.dart @@ -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()); + }); } diff --git a/engine/src/flutter/third_party/txt/src/txt/paragraph_builder.cc b/engine/src/flutter/third_party/txt/src/txt/paragraph_builder.cc index 1a34b367a2..cd9d159149 100644 --- a/engine/src/flutter/third_party/txt/src/txt/paragraph_builder.cc +++ b/engine/src/flutter/third_party/txt/src/txt/paragraph_builder.cc @@ -84,6 +84,7 @@ std::unique_ptr ParagraphBuilder::Build() { paragraph->SetText(std::move(text_), std::move(runs_)); paragraph->SetParagraphStyle(paragraph_style_); paragraph->SetFontCollection(font_collection_); + SetParagraphStyle(paragraph_style_); return paragraph; }