From fdabbc319904b592b31bb0f7acf2369b123dea77 Mon Sep 17 00:00:00 2001 From: etkmao Date: Fri, 26 Jul 2024 21:26:18 +0800 Subject: [PATCH] fix(core): check crash on config SetScaleFactor --- dom/src/dom/taitank_layout_node.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/dom/src/dom/taitank_layout_node.cc b/dom/src/dom/taitank_layout_node.cc index a21024d6c73..0a3a9824809 100644 --- a/dom/src/dom/taitank_layout_node.cc +++ b/dom/src/dom/taitank_layout_node.cc @@ -636,7 +636,9 @@ void TaitankLayoutNode::SetPosition(Edge edge, float position) { void TaitankLayoutNode::SetScaleFactor(float sacle_factor) { assert(engine_node_ != nullptr); TaitankConfigRef config = engine_node_->GetConfig(); - config->SetScaleFactor(sacle_factor); + if (config) { + config->SetScaleFactor(sacle_factor); + } } void TaitankLayoutNode::SetMaxWidth(float max_width) { @@ -809,6 +811,7 @@ void TaitankLayoutNode::Allocate() { engine_node_ = new TaitankNode(); } void TaitankLayoutNode::Deallocate() { if (engine_node_ == nullptr) return; delete engine_node_; + engine_node_ = nullptr; } std::shared_ptr CreateLayoutNode() { return std::make_shared(); }