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 2018/10/24 04:13:52 UTC
[incubator-weex] branch master updated: [iOS] Fix crash if observer
is removed twice. Change some variables to static. (#1665)
This is an automated email from the ASF dual-hosted git repository.
cxfeng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-weex.git
The following commit(s) were added to refs/heads/master by this push:
new 4351ca7 [iOS] Fix crash if observer is removed twice. Change some variables to static. (#1665)
4351ca7 is described below
commit 4351ca79dd1480112965c63261d78a5cd954811d
Author: wqyfavor <wq...@163.com>
AuthorDate: Wed Oct 24 12:13:46 2018 +0800
[iOS] Fix crash if observer is removed twice. Change some variables to static. (#1665)
---
ios/sdk/WeexSDK/Sources/Model/WXSDKInstance.m | 10 +++++++---
ios/sdk/WeexSDK/Sources/Monitor/WXMonitor.m | 6 ++----
ios/sdk/WeexSDK/Sources/Network/WXResourceRequest.m | 4 ++--
3 files changed, 11 insertions(+), 9 deletions(-)
diff --git a/ios/sdk/WeexSDK/Sources/Model/WXSDKInstance.m b/ios/sdk/WeexSDK/Sources/Model/WXSDKInstance.m
index c422284..8453d41 100644
--- a/ios/sdk/WeexSDK/Sources/Model/WXSDKInstance.m
+++ b/ios/sdk/WeexSDK/Sources/Model/WXSDKInstance.m
@@ -87,7 +87,6 @@ typedef enum : NSUInteger {
{
[_moduleEventObservers removeAllObjects];
[self removeObservers];
- [[NSNotificationCenter defaultCenter] removeObserver:self];
if (_syncDestroyComponentManager) {
WXPerformBlockSyncOnComponentThread(^{
_componentManager = nil;
@@ -922,12 +921,17 @@ typedef enum : NSUInteger {
[[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 9148354..1abe38f 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 27a5905..9227f8c 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