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/02 08:40:13 UTC

[2/4] incubator-weex git commit: * [ios] remove observer if add it

* [ios] remove observer if add 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/4f3ee573
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/4f3ee573
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/4f3ee573

Branch: refs/heads/0.14-dev
Commit: 4f3ee57303322bc379e25ad3e0cb0f419b94f333
Parents: 45a69d6
Author: acton393 <zh...@gmail.com>
Authored: Fri May 26 20:22:38 2017 +0800
Committer: acton393 <zh...@gmail.com>
Committed: Fri May 26 20:22:38 2017 +0800

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


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/4f3ee573/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 c12d487..08a92f1 100644
--- a/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m
+++ b/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m
@@ -116,6 +116,8 @@ CGFloat WXTextDefaultLineThroughWidth = 1.2;
     CGFloat _lineHeight;
     CGFloat _letterSpacing;
     BOOL _truncationLine; // support trunk tail
+    
+    BOOL _notifyRepaint;
 }
 
 + (void)setRenderUsingCoreText:(BOOL)usingCoreText
@@ -137,6 +139,7 @@ CGFloat WXTextDefaultLineThroughWidth = 1.2;
 {
     self = [super initWithRef:ref type:type styles:styles attributes:attributes events:events weexInstance:weexInstance];
     if (self) {
+        _notifyRepaint = NO;
         // just for coretext and textkit render replacement
         if ([attributes objectForKey:@"coretext"]) {
             _useCoreTextAttr = [WXConvert NSString:attributes[@"coretext"]];
@@ -169,7 +172,9 @@ CGFloat WXTextDefaultLineThroughWidth = 1.2;
 
 - (void)dealloc
 {
-    [[NSNotificationCenter defaultCenter] removeObserver:self];
+    if (_notifyRepaint) {
+        [[NSNotificationCenter defaultCenter] removeObserver:self name:WX_ICONFONT_DOWNLOAD_NOTIFICATION object:nil];
+    }
 }
 
 #define WX_STYLE_FILL_TEXT(key, prop, type, needLayout)\
@@ -361,6 +366,7 @@ do {\
         //custom localSrc is cached
         if (!fontLocalSrc && fontSrc) {
             // if use custom font, when the custom font download finish, refresh text.
+            _notifyRepaint = YES;
             [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(repaintText:) name:WX_ICONFONT_DOWNLOAD_NOTIFICATION object:nil];
         }
     }