You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by cx...@apache.org on 2017/03/03 11:16:15 UTC

[2/2] incubator-weex git commit: * [ios] add crash protect to recycler

* [ios] add crash protect to recycler


Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/660a01ed
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/660a01ed
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/660a01ed

Branch: refs/heads/0.11-dev-feature-recycler
Commit: 660a01ed942a28d6eff710e591434aa3ef03e413
Parents: 6776448
Author: cxfeng <cx...@gmail.com>
Authored: Fri Mar 3 19:15:16 2017 +0800
Committer: cxfeng <cx...@gmail.com>
Committed: Fri Mar 3 19:15:16 2017 +0800

----------------------------------------------------------------------
 .../Sources/Component/Recycler/WXMultiColumnLayout.h        | 2 +-
 .../Sources/Component/Recycler/WXMultiColumnLayout.m        | 3 +++
 .../Sources/Component/Recycler/WXRecyclerUpdateController.m | 9 +++++++++
 3 files changed, 13 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/660a01ed/ios/sdk/WeexSDK/Sources/Component/Recycler/WXMultiColumnLayout.h
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Component/Recycler/WXMultiColumnLayout.h b/ios/sdk/WeexSDK/Sources/Component/Recycler/WXMultiColumnLayout.h
index c28180d..f107db0 100644
--- a/ios/sdk/WeexSDK/Sources/Component/Recycler/WXMultiColumnLayout.h
+++ b/ios/sdk/WeexSDK/Sources/Component/Recycler/WXMultiColumnLayout.h
@@ -27,7 +27,7 @@ extern NSString * const kCollectionSupplementaryViewKindHeader;
 
 @interface WXMultiColumnLayout : UICollectionViewLayout
 
-@property (nonatomic, assign) id<WXMultiColumnLayoutDelegate> delegate;
+@property (nonatomic, weak) id<WXMultiColumnLayoutDelegate> delegate;
 
 @property (nonatomic, strong) WXLength *columnCount;
 

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/660a01ed/ios/sdk/WeexSDK/Sources/Component/Recycler/WXMultiColumnLayout.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Component/Recycler/WXMultiColumnLayout.m b/ios/sdk/WeexSDK/Sources/Component/Recycler/WXMultiColumnLayout.m
index d6f9cdb..f5d641e 100644
--- a/ios/sdk/WeexSDK/Sources/Component/Recycler/WXMultiColumnLayout.m
+++ b/ios/sdk/WeexSDK/Sources/Component/Recycler/WXMultiColumnLayout.m
@@ -319,6 +319,9 @@ NSString * const kMultiColumnLayoutCell = @"WXMultiColumnLayoutCell";
     float columnWidth ;
     float availableWidth = self.contentWidth - (insets.left + insets.right);
     computeColumnWidthAndCount(availableWidth, self.columnCount, self.columnWidth, self.columnGap, &columnCount, &columnWidth);
+    if (availableWidth <= 0) {
+        return;
+    }
     WXAssert(columnCount > 0, @"invalid column count");
     WXAssert(columnWidth > 0, @"invalid column width");
     

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/660a01ed/ios/sdk/WeexSDK/Sources/Component/Recycler/WXRecyclerUpdateController.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Component/Recycler/WXRecyclerUpdateController.m b/ios/sdk/WeexSDK/Sources/Component/Recycler/WXRecyclerUpdateController.m
index 17090b0..31c9dd0 100644
--- a/ios/sdk/WeexSDK/Sources/Component/Recycler/WXRecyclerUpdateController.m
+++ b/ios/sdk/WeexSDK/Sources/Component/Recycler/WXRecyclerUpdateController.m
@@ -87,6 +87,10 @@
 
 - (void)reloadItemsAtIndexPath:(NSIndexPath *)indexPath
 {
+    if (!indexPath) {
+        return;
+    }
+    
     if (!_reloadIndexPaths) {
         _reloadIndexPaths = [NSMutableSet set];
     }
@@ -143,8 +147,13 @@
     
     self.isUpdating = YES;
     
+    if (!self.delegate) {
+        return;
+    }
+    
     [self.delegate updateController:self willPerformUpdateWithNewData:newData];
     
+    NSLog(@"Diff result:%@", diffResult);
     [collectionView performBatchUpdates:updates completion:completion];
 }