Repository: incubator-weex Updated Branches: refs/heads/master eeb91706d -> a13225f60
[WEEX-456][ios]try to fix bas_access of parentNode Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/a13225f6 Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/a13225f6 Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/a13225f6 Branch: refs/heads/master Commit: a13225f60817be2ae40391f2606fdc4850df29c3 Parents: eeb9170 Author: zhongcang <[email protected]> Authored: Wed Jun 13 15:35:08 2018 +0800 Committer: Adam Feng <[email protected]> Committed: Thu Jun 14 10:35:47 2018 +0800 ---------------------------------------------------------------------- ios/sdk/WeexSDK/Sources/Layout/WXCoreLayout.h | 3 ++- .../Sources/Manager/WXComponentManager.mm | 19 ++++++++++++++++++- ios/sdk/WeexSDK/Sources/Model/WXComponent.mm | 7 +++---- 3 files changed, 23 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/a13225f6/ios/sdk/WeexSDK/Sources/Layout/WXCoreLayout.h ---------------------------------------------------------------------- diff --git a/ios/sdk/WeexSDK/Sources/Layout/WXCoreLayout.h b/ios/sdk/WeexSDK/Sources/Layout/WXCoreLayout.h index 216c099..e1827c5 100644 --- a/ios/sdk/WeexSDK/Sources/Layout/WXCoreLayout.h +++ b/ios/sdk/WeexSDK/Sources/Layout/WXCoreLayout.h @@ -703,9 +703,10 @@ namespace WeexCore { return mChildList.cend(); } - inline void removeChild(const WXCoreLayoutNode* const child) { + inline void removeChild(WXCoreLayoutNode* const child) { for (int index = 0; index < mChildList.size(); index++) { if (child == mChildList[index]) { + child->mParent = nullptr; mChildList.erase(mChildList.begin() + index); break; } http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/a13225f6/ios/sdk/WeexSDK/Sources/Manager/WXComponentManager.mm ---------------------------------------------------------------------- diff --git a/ios/sdk/WeexSDK/Sources/Manager/WXComponentManager.mm b/ios/sdk/WeexSDK/Sources/Manager/WXComponentManager.mm index ed3e9f0..3fa3f33 100644 --- a/ios/sdk/WeexSDK/Sources/Manager/WXComponentManager.mm +++ b/ios/sdk/WeexSDK/Sources/Manager/WXComponentManager.mm @@ -986,9 +986,26 @@ static NSThread *WXComponentThread; - (void)removeFixedComponent:(WXComponent *)fixComponent { [_fixedComponents removeObject:fixComponent]; - _rootFlexCSSNode->removeChild(fixComponent->_flexCssNode); + [self removeFixFlexNode:fixComponent->_flexCssNode]; } +- (void)removeFixFlexNode:(WeexCore::WXCoreLayoutNode* )fixNode{ + if (nullptr == fixNode) { + return; + } + if ([[NSThread currentThread].name isEqualToString:WX_COMPONENT_THREAD_NAME]) { + _rootFlexCSSNode->removeChild(fixNode); + }else{ + WXPerformBlockOnComponentThread(^{ + if (nullptr == fixNode) { + return; + } + _rootFlexCSSNode->removeChild(fixNode); + }); + } +} + + @end void WXPerformBlockOnComponentThread(void (^block)(void)) http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/a13225f6/ios/sdk/WeexSDK/Sources/Model/WXComponent.mm ---------------------------------------------------------------------- diff --git a/ios/sdk/WeexSDK/Sources/Model/WXComponent.mm b/ios/sdk/WeexSDK/Sources/Model/WXComponent.mm index f383ad8..58df862 100644 --- a/ios/sdk/WeexSDK/Sources/Model/WXComponent.mm +++ b/ios/sdk/WeexSDK/Sources/Model/WXComponent.mm @@ -222,6 +222,9 @@ static BOOL bNeedRemoveEvents = YES; - (void)dealloc { + if (_positionType == WXPositionTypeFixed) { + [self.weexInstance.componentManager removeFixedComponent:self]; + } if(_flexCssNode){ #ifdef DEBUG WXLogDebug(@"flexLayout -> dealloc %@",self.ref); @@ -257,10 +260,6 @@ static BOOL bNeedRemoveEvents = YES; } } - if (_positionType == WXPositionTypeFixed) { - [self.weexInstance.componentManager removeFixedComponent:self]; - } - pthread_mutex_destroy(&_propertyMutex); pthread_mutexattr_destroy(&_propertMutexAttr);
