You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by ac...@apache.org on 2017/06/28 06:53:00 UTC

incubator-weex git commit: * [ios] try to fix text crash when draw it

Repository: incubator-weex
Updated Branches:
  refs/heads/0.15-dev 43bd95bb3 -> 4a33ccdb6


* [ios] try to fix text crash when draw it


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

Branch: refs/heads/0.15-dev
Commit: 4a33ccdb6c979fd9e9bccf9d7c3ff3dd5148dfdf
Parents: 43bd95b
Author: acton393 <zh...@gmail.com>
Authored: Wed Jun 28 14:52:55 2017 +0800
Committer: acton393 <zh...@gmail.com>
Committed: Wed Jun 28 14:52:55 2017 +0800

----------------------------------------------------------------------
 ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/4a33ccdb/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m b/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m
index 43976bd..6cbe8e0 100644
--- a/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m
+++ b/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m
@@ -640,8 +640,12 @@ do {\
         if (_coreTextFrameRef) {
             CFRelease(_coreTextFrameRef);
         }
-        _coreTextFrameRef = CTFramesetterCreateFrame([self ctFramesetterRef], CFRangeMake(0, 0), cgPath, NULL);
+        _coreTextFrameRef = CTFramesetterCreateFrame([self ctFramesetterRef], CFRangeMake(0, attributedStringCopy.length), cgPath, NULL);
         CFArrayRef ctLines = NULL;
+        if (NULL == _coreTextFrameRef) {
+            // try to protect crash from frame is NULL
+            return;
+        }
         ctLines = CTFrameGetLines(_coreTextFrameRef);
         CFIndex lineCount = CFArrayGetCount(ctLines);
         NSMutableArray * mutableLines = [NSMutableArray new];
@@ -853,6 +857,10 @@ do {\
     CGPathRelease(path);
     
     CFArrayRef lines = NULL;
+    if (NULL == frameRef) {
+        //try to protect unexpected crash.
+        return suggestSize;
+    }
     lines = CTFrameGetLines(frameRef);
     CFIndex lineCount = CFArrayGetCount(lines);
     CGFloat ascent = 0;