aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Muxi Yan <muxi@users.noreply.github.com>2018-02-05 15:45:33 -0800
committerGravatar GitHub <noreply@github.com>2018-02-05 15:45:33 -0800
commitcd3f579cce2607a6edaa64f7c3f156e2c7907de4 (patch)
treef89d52efc51a8e54f71ee9d46979f5d0f0cf097b
parent42b6af7ab441c6938fc0b9179ec5843e9a174b92 (diff)
parent45ca2022cd3dfd19635dbabf3aece3b8953d686b (diff)
Merge pull request #14314 from muxi/fix-implicit-retain-self
Fix reference of self in a block
-rw-r--r--src/objective-c/ProtoRPC/ProtoMethod.m3
-rw-r--r--src/objective-c/ProtoRPC/ProtoRPC.m3
-rw-r--r--src/objective-c/ProtoRPC/ProtoService.m3
-rw-r--r--src/objective-c/RxLibrary/GRXConcurrentWriteable.m30
4 files changed, 26 insertions, 13 deletions
diff --git a/src/objective-c/ProtoRPC/ProtoMethod.m b/src/objective-c/ProtoRPC/ProtoMethod.m
index 4bef10af0e..ed585acfb9 100644
--- a/src/objective-c/ProtoRPC/ProtoMethod.m
+++ b/src/objective-c/ProtoRPC/ProtoMethod.m
@@ -18,7 +18,10 @@
#import "ProtoMethod.h"
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-implementations"
@implementation ProtoMethod
+#pragma clang diagnostic pop
- (instancetype)initWithPackage:(NSString *)package
service:(NSString *)service
method:(NSString *)method {
diff --git a/src/objective-c/ProtoRPC/ProtoRPC.m b/src/objective-c/ProtoRPC/ProtoRPC.m
index 1ecfcc5b0e..20b9d04cd8 100644
--- a/src/objective-c/ProtoRPC/ProtoRPC.m
+++ b/src/objective-c/ProtoRPC/ProtoRPC.m
@@ -42,7 +42,10 @@ static NSError *ErrorForBadProto(id proto, Class expectedClass, NSError *parsing
userInfo:info];
}
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-implementations"
@implementation ProtoRPC {
+#pragma clang diagnostic pop
id<GRXWriteable> _responseWriteable;
}
diff --git a/src/objective-c/ProtoRPC/ProtoService.m b/src/objective-c/ProtoRPC/ProtoService.m
index be6089f0a4..611cee46bf 100644
--- a/src/objective-c/ProtoRPC/ProtoService.m
+++ b/src/objective-c/ProtoRPC/ProtoService.m
@@ -24,7 +24,10 @@
#import "ProtoMethod.h"
#import "ProtoRPC.h"
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-implementations"
@implementation ProtoService {
+#pragma clang diagnostic pop
NSString *_host;
NSString *_packageName;
NSString *_serviceName;
diff --git a/src/objective-c/RxLibrary/GRXConcurrentWriteable.m b/src/objective-c/RxLibrary/GRXConcurrentWriteable.m
index 37bc975f87..c262313496 100644
--- a/src/objective-c/RxLibrary/GRXConcurrentWriteable.m
+++ b/src/objective-c/RxLibrary/GRXConcurrentWriteable.m
@@ -64,21 +64,25 @@
}
- (void)enqueueSuccessfulCompletion {
+ __weak typeof(self) weakSelf = self;
dispatch_async(_writeableQueue, ^{
- BOOL finished = NO;
- @synchronized (self) {
- if (!_alreadyFinished) {
- _alreadyFinished = YES;
- } else {
- finished = YES;
+ typeof(self) strongSelf = weakSelf;
+ if (strongSelf) {
+ BOOL finished = NO;
+ @synchronized (self) {
+ if (!strongSelf->_alreadyFinished) {
+ strongSelf->_alreadyFinished = YES;
+ } else {
+ finished = YES;
+ }
+ }
+ if (!finished) {
+ // Cancellation is now impossible. None of the other three blocks can run concurrently with
+ // this one.
+ [self.writeable writesFinishedWithError:nil];
+ // Skip any possible message to the wrapped writeable enqueued after this one.
+ self.writeable = nil;
}
- }
- if (!finished) {
- // Cancellation is now impossible. None of the other three blocks can run concurrently with
- // this one.
- [self.writeable writesFinishedWithError:nil];
- // Skip any possible message to the wrapped writeable enqueued after this one.
- self.writeable = nil;
}
});
}