Repository: incubator-weex
Updated Branches:
  refs/heads/master af911f780 -> ce7c929d4


[WEEX-121][iOS] bug-fix draw text crash

 there are case when text update frequently, so when main thread drawing text, 
here updates come,
so the text value must protect here from be setting in multithread, here use 
lock temporarily.

Bug:121


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

Branch: refs/heads/master
Commit: 76dd76d06e0813b192a4c82ca17617601fe4760c
Parents: 6617a0d
Author: acton393 <zhangxing610...@gmail.com>
Authored: Thu Nov 16 12:09:59 2017 +0800
Committer: acton393 <zhangxing610...@gmail.com>
Committed: Thu Nov 16 12:09:59 2017 +0800

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


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/76dd76d0/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 8b292d4..2fbd925 100644
--- a/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m
+++ b/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m
@@ -249,8 +249,8 @@ do {\
 - (void)fillAttributes:(NSDictionary *)attributes
 {
     id text = attributes[@"value"];
-    if (text) {
-        _text = [WXConvert NSString:text];
+    if (text && ![[self text] isEqualToString:text]) {
+        [self setText:[WXConvert NSString:text]];
         [self setNeedsRepaint];
         [self setNeedsLayout];
     }
@@ -361,6 +361,12 @@ do {\
 {
     return _text;
 }
+- (void)setText:(NSString*)text
+{
+    pthread_mutex_lock(&(_ctAttributedStringMutex));
+    _text = text;
+    pthread_mutex_unlock(&(_ctAttributedStringMutex));
+}
 
 - (NSAttributedString *)ctAttributedString
 {

Reply via email to