You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by GitBox <gi...@apache.org> on 2018/10/24 04:13:47 UTC

[GitHub] cxfeng1 closed pull request #1665: [iOS] Fix crash if observer is removed twice. Change some variables t…

cxfeng1 closed pull request #1665: [iOS] Fix crash if observer is removed twice. Change some variables t…
URL: https://github.com/apache/incubator-weex/pull/1665
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/ios/sdk/WeexSDK/Sources/Model/WXSDKInstance.m b/ios/sdk/WeexSDK/Sources/Model/WXSDKInstance.m
index c422284cc9..8453d41301 100644
--- a/ios/sdk/WeexSDK/Sources/Model/WXSDKInstance.m
+++ b/ios/sdk/WeexSDK/Sources/Model/WXSDKInstance.m
@@ -87,7 +87,6 @@ - (void)dealloc
 {
     [_moduleEventObservers removeAllObjects];
     [self removeObservers];
-    [[NSNotificationCenter defaultCenter] removeObserver:self];
     if (_syncDestroyComponentManager) {
         WXPerformBlockSyncOnComponentThread(^{
             _componentManager = nil;
@@ -922,12 +921,17 @@ - (void)addObservers
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moduleEventNotification:) name:WX_MODULE_EVENT_FIRE_NOTIFICATION object:nil];
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationWillResignActive:) name:UIApplicationWillResignActiveNotification object:nil];
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationDidBecomeActive:) name:UIApplicationDidBecomeActiveNotification object:nil];
-    [self addObserver:self forKeyPath:@"state" options:NSKeyValueObservingOptionNew context:nil];
+    [self addObserver:self forKeyPath:@"state" options:NSKeyValueObservingOptionNew context:NULL];
 }
 
 - (void)removeObservers
 {
-    [self removeObserver:self forKeyPath:@"state"];
+    @try {
+        [self removeObserver:self forKeyPath:@"state" context:NULL];
+        [[NSNotificationCenter defaultCenter] removeObserver:self];
+    }
+    @catch (NSException *exception) {
+    }
 }
 
 - (void)applicationWillResignActive:(NSNotification*)notification
diff --git a/ios/sdk/WeexSDK/Sources/Monitor/WXMonitor.m b/ios/sdk/WeexSDK/Sources/Monitor/WXMonitor.m
index 914835456d..1abe38f83d 100644
--- a/ios/sdk/WeexSDK/Sources/Monitor/WXMonitor.m
+++ b/ios/sdk/WeexSDK/Sources/Monitor/WXMonitor.m
@@ -30,12 +30,10 @@
 #import "WXTracingManager.h"
 #import "WXAnalyzerProtocol.h"
 #import "WXSDKInstance_performance.h"
-
 #import "WXAnalyzerCenter+Transfer.h"
 
-
-NSString *const kStartKey = @"start";
-NSString *const kEndKey = @"end";
+static NSString *const kStartKey = @"start";
+static NSString *const kEndKey = @"end";
 
 @implementation WXMonitor
 
diff --git a/ios/sdk/WeexSDK/Sources/Network/WXResourceRequest.m b/ios/sdk/WeexSDK/Sources/Network/WXResourceRequest.m
index 27a5905816..9227f8c115 100644
--- a/ios/sdk/WeexSDK/Sources/Network/WXResourceRequest.m
+++ b/ios/sdk/WeexSDK/Sources/Network/WXResourceRequest.m
@@ -19,8 +19,8 @@
 
 #import "WXResourceRequest.h"
 
-NSString * const kHTTPHeaderNameUserAgent = @"User-Agent";
-NSString * const kHTTPHeaderNameReferrer = @"Referer"; // The misspelling referer originated in the original proposal by computer "scientist" Phillip Hallam-Baker to incorporate the field into the HTTP specification. ╮(╯_╰)╭
+static NSString * const kHTTPHeaderNameUserAgent = @"User-Agent";
+static NSString * const kHTTPHeaderNameReferrer = @"Referer"; // The misspelling referer originated in the original proposal by computer "scientist" Phillip Hallam-Baker to incorporate the field into the HTTP specification. ╮(╯_╰)╭
 
 @implementation WXResourceRequest
 


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services