From 43f5edb6f8daece2797adc10947e19844dfa14ba Mon Sep 17 00:00:00 2001 From: "qianyuan.wqy" Date: Wed, 9 Oct 2019 11:05:13 +0800 Subject: [PATCH] Add clearBFCs method and clear BFCs after self-layout of scroller node. --- ios/sdk/WeexSDK/Sources/Component/WXScrollerComponent.mm | 5 +++++ weex_core/Source/core/layout/layout.h | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/ios/sdk/WeexSDK/Sources/Component/WXScrollerComponent.mm b/ios/sdk/WeexSDK/Sources/Component/WXScrollerComponent.mm index 4d3f4c9110..981a7afe65 100644 --- a/ios/sdk/WeexSDK/Sources/Component/WXScrollerComponent.mm +++ b/ios/sdk/WeexSDK/Sources/Component/WXScrollerComponent.mm @@ -1152,6 +1152,11 @@ - (void)_layoutPlatform _flexCssNode->calculateLayout(renderPageSize); _flexCssNode->setParent(parent, _flexCssNode); + /* We must clear BFCs becuase we have set parent of _flexCSSNode to nullptr and + manually called its calculateLayout method. This will cause a non-bfc layout node + to have items in its BFCs vector. Later, a wild pointer may cause crash. */ + _flexCssNode->clearBFCs(); + // set origin and size back _flexCssNode->rewriteLayoutResult(left, top, width, height); } diff --git a/weex_core/Source/core/layout/layout.h b/weex_core/Source/core/layout/layout.h index 621797224e..e8d58f7d33 100644 --- a/weex_core/Source/core/layout/layout.h +++ b/weex_core/Source/core/layout/layout.h @@ -731,6 +731,10 @@ namespace WeexCore { markDirty(); } + + inline void clearBFCs() { + BFCs.clear(); + } inline void addChildAt(WXCoreLayoutNode* const child, Index index) { mChildList.insert(mChildList.begin() + index, child);