aboutsummaryrefslogtreecommitdiffhomepage
path: root/Firestore/Source
diff options
context:
space:
mode:
authorGravatar rsgowman <rgowman@google.com>2018-02-21 12:09:05 -0500
committerGravatar GitHub <noreply@github.com>2018-02-21 12:09:05 -0500
commit67b068e528ace4970cb21912ce9350cc1d0e292d (patch)
treeb00a1a5075fdc9cfa721a807c3d4b16f89322685 /Firestore/Source
parent14ea068f5fd03a658017f8472a4078a727fabc3a (diff)
Fix implicit retain self warnings (#808)
Xcode has starting warning about us implicitly retaining self references within blocks. This commit fixes it by explicitly mentioning self. No real changes are introduced here; this is effectively just making implicit behaviour explicit.
Diffstat (limited to 'Firestore/Source')
-rw-r--r--Firestore/Source/Auth/FSTCredentialsProvider.mm8
-rw-r--r--Firestore/Source/Remote/FSTRemoteStore.mm4
-rw-r--r--Firestore/Source/Util/FSTAsyncQueryListener.mm11
3 files changed, 14 insertions, 9 deletions
diff --git a/Firestore/Source/Auth/FSTCredentialsProvider.mm b/Firestore/Source/Auth/FSTCredentialsProvider.mm
index 084f313..c3fbeb0 100644
--- a/Firestore/Source/Auth/FSTCredentialsProvider.mm
+++ b/Firestore/Source/Auth/FSTCredentialsProvider.mm
@@ -86,12 +86,12 @@ NS_ASSUME_NONNULL_BEGIN
NSString *userID = userInfo[FIRAuthStateDidChangeInternalNotificationUIDKey];
User newUser = User(userID);
- if (newUser != _currentUser) {
- _currentUser = newUser;
+ if (newUser != self->_currentUser) {
+ self->_currentUser = newUser;
self.userCounter++;
FSTVoidUserBlock listenerBlock = self.userChangeListener;
if (listenerBlock) {
- listenerBlock(_currentUser);
+ listenerBlock(self->_currentUser);
}
}
}
@@ -121,7 +121,7 @@ NS_ASSUME_NONNULL_BEGIN
userInfo:errorInfo];
completion(Token::Invalid(), cancelError);
} else {
- completion(Token(util::MakeStringView(token), _currentUser), error);
+ completion(Token(util::MakeStringView(token), self->_currentUser), error);
}
};
};
diff --git a/Firestore/Source/Remote/FSTRemoteStore.mm b/Firestore/Source/Remote/FSTRemoteStore.mm
index c6668bf..b2e4013 100644
--- a/Firestore/Source/Remote/FSTRemoteStore.mm
+++ b/Firestore/Source/Remote/FSTRemoteStore.mm
@@ -507,10 +507,10 @@ static const int kOnlineAttemptsBeforeFailure = 2;
FSTBoxedTargetID *target, FSTTargetChange *change, BOOL *stop) {
NSData *resumeToken = change.resumeToken;
if (resumeToken.length > 0) {
- FSTQueryData *queryData = _listenTargets[target];
+ FSTQueryData *queryData = self->_listenTargets[target];
// A watched target might have been removed already.
if (queryData) {
- _listenTargets[target] =
+ self->_listenTargets[target] =
[queryData queryDataByReplacingSnapshotVersion:change.snapshotVersion
resumeToken:resumeToken];
}
diff --git a/Firestore/Source/Util/FSTAsyncQueryListener.mm b/Firestore/Source/Util/FSTAsyncQueryListener.mm
index d98e2dd..b72ac57 100644
--- a/Firestore/Source/Util/FSTAsyncQueryListener.mm
+++ b/Firestore/Source/Util/FSTAsyncQueryListener.mm
@@ -34,10 +34,15 @@
}
- (FSTViewSnapshotHandler)asyncSnapshotHandler {
+ // Retain `self` strongly in resulting snapshot handler so that even if the
+ // user releases the `FSTAsyncQueryListener` we'll continue to deliver
+ // events. This is done specifically to facilitate the common case where
+ // users just want to turn on notifications "forever" and don't want to have
+ // to keep track of our handle to keep them going.
return ^(FSTViewSnapshot *_Nullable snapshot, NSError *_Nullable error) {
- [_dispatchQueue dispatchAsync:^{
- if (!_muted) {
- _snapshotHandler(snapshot, error);
+ [self->_dispatchQueue dispatchAsync:^{
+ if (!self->_muted) {
+ self->_snapshotHandler(snapshot, error);
}
}];
};