You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by to...@apache.org on 2018/03/08 11:21:06 UTC
incubator-weex git commit: * [iOS] fix multithread crash about
mutable array in scroller component [Forced Update!]
Repository: incubator-weex
Updated Branches:
refs/heads/master 9c9ae8846 -> ec0a1f9ba (forced update)
* [iOS] fix multithread crash about mutable array in scroller component
Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/ec0a1f9b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/ec0a1f9b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/ec0a1f9b
Branch: refs/heads/master
Commit: ec0a1f9ba29720f3b3559edc06bcfae855d28553
Parents: 4b0e374
Author: acton393 <zh...@gmail.com>
Authored: Thu Mar 8 15:27:44 2018 +0800
Committer: yuhun-alibaba <to...@gmail.com>
Committed: Thu Mar 8 19:19:32 2018 +0800
----------------------------------------------------------------------
ios/sdk/WeexSDK/Sources/Component/WXScrollerComponent.m | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/ec0a1f9b/ios/sdk/WeexSDK/Sources/Component/WXScrollerComponent.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Component/WXScrollerComponent.m b/ios/sdk/WeexSDK/Sources/Component/WXScrollerComponent.m
index 4ebaec5..ede9de3 100644
--- a/ios/sdk/WeexSDK/Sources/Component/WXScrollerComponent.m
+++ b/ios/sdk/WeexSDK/Sources/Component/WXScrollerComponent.m
@@ -28,6 +28,7 @@
#import "WXRefreshComponent.h"
#import "WXConfigCenterProtocol.h"
#import "WXSDKEngine.h"
+#import "WXThreadSafeMutableArray.h"
@interface WXScrollerComponnetView:UIScrollView
@end
@@ -50,7 +51,7 @@
@interface WXScrollerComponent()
@property (nonatomic, strong) NSMutableArray * stickyArray;
-@property (nonatomic, strong) NSMutableArray * listenerArray;
+@property (nonatomic, strong) WXThreadSafeMutableArray * listenerArray;
@property (nonatomic, weak) WXRefreshComponent *refreshComponent;
@property (nonatomic, weak) WXLoadingComponent *loadingComponent;
@@ -118,7 +119,7 @@ WX_EXPORT_METHOD(@selector(resetLoadmore))
if (self) {
_stickyArray = [NSMutableArray array];
- _listenerArray = [NSMutableArray array];
+ _listenerArray = [WXThreadSafeMutableArray array];
_scrollEvent = NO;
_scrollStartEvent = NO;
_scrollEndEvent = NO;
@@ -382,7 +383,8 @@ WX_EXPORT_METHOD(@selector(resetLoadmore))
- (void)addScrollToListener:(WXComponent *)target
{
BOOL has = NO;
- for (WXScrollToTarget *targetData in self.listenerArray) {
+ WXThreadSafeMutableArray *listenerArray = [self.listenerArray copy];
+ for (WXScrollToTarget *targetData in listenerArray) {
if (targetData.target == target) {
has = YES;
break;
@@ -400,7 +402,8 @@ WX_EXPORT_METHOD(@selector(resetLoadmore))
{
if (_shouldRemoveScrollerListener) {
WXScrollToTarget *targetData = nil;
- for (WXScrollToTarget *targetDataTemp in self.listenerArray) {
+ WXThreadSafeMutableArray *listenerArray = [self.listenerArray copy];
+ for (WXScrollToTarget *targetDataTemp in listenerArray) {
if (targetDataTemp.target == target) {
targetData = targetDataTemp;
break;