Skip to content

Commit 67b068e

Browse files
authored
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.
1 parent 14ea068 commit 67b068e

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
lines changed

Firestore/Source/Auth/FSTCredentialsProvider.mm

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,12 @@ - (instancetype)initWithApp:(FIRApp *)app {
8686

8787
NSString *userID = userInfo[FIRAuthStateDidChangeInternalNotificationUIDKey];
8888
User newUser = User(userID);
89-
if (newUser != _currentUser) {
90-
_currentUser = newUser;
89+
if (newUser != self->_currentUser) {
90+
self->_currentUser = newUser;
9191
self.userCounter++;
9292
FSTVoidUserBlock listenerBlock = self.userChangeListener;
9393
if (listenerBlock) {
94-
listenerBlock(_currentUser);
94+
listenerBlock(self->_currentUser);
9595
}
9696
}
9797
}
@@ -121,7 +121,7 @@ - (void)getTokenForcingRefresh:(BOOL)forceRefresh
121121
userInfo:errorInfo];
122122
completion(Token::Invalid(), cancelError);
123123
} else {
124-
completion(Token(util::MakeStringView(token), _currentUser), error);
124+
completion(Token(util::MakeStringView(token), self->_currentUser), error);
125125
}
126126
};
127127
};

Firestore/Source/Remote/FSTRemoteStore.mm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -507,10 +507,10 @@ - (void)processBatchedWatchChanges:(NSArray<FSTWatchChange *> *)changes
507507
FSTBoxedTargetID *target, FSTTargetChange *change, BOOL *stop) {
508508
NSData *resumeToken = change.resumeToken;
509509
if (resumeToken.length > 0) {
510-
FSTQueryData *queryData = _listenTargets[target];
510+
FSTQueryData *queryData = self->_listenTargets[target];
511511
// A watched target might have been removed already.
512512
if (queryData) {
513-
_listenTargets[target] =
513+
self->_listenTargets[target] =
514514
[queryData queryDataByReplacingSnapshotVersion:change.snapshotVersion
515515
resumeToken:resumeToken];
516516
}

Firestore/Source/Util/FSTAsyncQueryListener.mm

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,15 @@ - (instancetype)initWithDispatchQueue:(FSTDispatchQueue *)dispatchQueue
3434
}
3535

3636
- (FSTViewSnapshotHandler)asyncSnapshotHandler {
37+
// Retain `self` strongly in resulting snapshot handler so that even if the
38+
// user releases the `FSTAsyncQueryListener` we'll continue to deliver
39+
// events. This is done specifically to facilitate the common case where
40+
// users just want to turn on notifications "forever" and don't want to have
41+
// to keep track of our handle to keep them going.
3742
return ^(FSTViewSnapshot *_Nullable snapshot, NSError *_Nullable error) {
38-
[_dispatchQueue dispatchAsync:^{
39-
if (!_muted) {
40-
_snapshotHandler(snapshot, error);
43+
[self->_dispatchQueue dispatchAsync:^{
44+
if (!self->_muted) {
45+
self->_snapshotHandler(snapshot, error);
4146
}
4247
}];
4348
};

0 commit comments

Comments
 (0)