Skip to content
This repository has been archived by the owner on Jun 3, 2021. It is now read-only.

Commit

Permalink
[WEEX-501][iOS] Try to fix insert table view cell exception abort on iOS
Browse files Browse the repository at this point in the history
  • Loading branch information
caixiaomin committed Jul 12, 2018
1 parent 44a3c41 commit bedc6aa
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 2 deletions.
8 changes: 6 additions & 2 deletions ios/sdk/WeexSDK/Sources/Component/WXListComponent.mm
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#import "WXRefreshComponent.h"
#import "WXLoadingComponent.h"
#import "WXScrollerComponent+Layout.h"
#import "WXThreadSafeMutableArray.h"

@interface WXTableView : UITableView

Expand Down Expand Up @@ -94,8 +95,11 @@ @implementation WXSectionComponent
- (instancetype)init
{
if (self = [super init]) {
_rows = [NSMutableArray array];
}
if ([WXUtility listSectionRowThreadSafe]) {
_rows = [WXThreadSafeMutableArray array];
} else {
_rows = [NSMutableArray array];
} }

return self;
}
Expand Down
3 changes: 3 additions & 0 deletions ios/sdk/WeexSDK/Sources/Model/WXSDKInstance.m
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,9 @@ - (BOOL)_handleConfigCenter
BOOL unregisterFontWhenCollision = [[configCenter configForKey:@"iOS_weex_ext_config.unregisterFontWhenCollision" defaultValue:@NO isDefault:NULL] boolValue];
[WXUtility setUnregisterFontWhenCollision:unregisterFontWhenCollision];

BOOL listSectionRowThreadSafe = [[configCenter configForKey:@"iOS_weex_ext_config.listSectionRowThreadSafe" defaultValue:@(YES) isDefault:NULL] boolValue];
[WXUtility setListSectionRowThreadSafe:listSectionRowThreadSafe];

//Reading config from orange for Release instance in Main Thread or not
_bReleaseInstanceInMainThread = [[configCenter configForKey:@"iOS_weex_ext_config.releaseInstanceInMainThread" defaultValue:@(YES) isDefault:nil] boolValue];

Expand Down
4 changes: 4 additions & 0 deletions ios/sdk/WeexSDK/Sources/Utility/WXUtility.h
Original file line number Diff line number Diff line change
Expand Up @@ -489,4 +489,8 @@ BOOL WXFloatGreaterThanWithPrecision(CGFloat a,CGFloat b,double precision);

+ (void)setUnregisterFontWhenCollision:(BOOL)value;

+ (void)setListSectionRowThreadSafe:(BOOL)value;

+ (BOOL)listSectionRowThreadSafe;

@end
11 changes: 11 additions & 0 deletions ios/sdk/WeexSDK/Sources/Utility/WXUtility.m
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@

static BOOL threadSafeCollectionUsingLock = YES;
static BOOL unregisterFontWhenCollision = NO;
static BOOL listSectionRowThreadSafe = YES;

void WXPerformBlockOnMainThread(void (^ _Nonnull block)(void))
{
Expand Down Expand Up @@ -153,6 +154,16 @@ + (void)setUnregisterFontWhenCollision:(BOOL)value
unregisterFontWhenCollision = value;
}

+ (void)setListSectionRowThreadSafe:(BOOL)value
{
listSectionRowThreadSafe = value;
}

+ (BOOL)listSectionRowThreadSafe
{
return listSectionRowThreadSafe;
}

+ (void)performBlock:(void (^)(void))block onThread:(NSThread *)thread
{
if (!thread || !block) return;
Expand Down

0 comments on commit bedc6aa

Please sign in to comment.