Skip to content

Commit 131234c

Browse files
committed
Break retain cycles
These were always present, but weren't obvious due to obj-c implicitly retaining self (which there's no an warning enabled to catch.)
1 parent 91bd7c7 commit 131234c

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

Firestore/Source/Remote/FSTRemoteStore.mm

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#import "Firestore/Source/Remote/FSTStream.h"
3434
#import "Firestore/Source/Remote/FSTWatchChange.h"
3535
#import "Firestore/Source/Util/FSTAssert.h"
36+
#import "Firestore/Source/Util/FSTClasses.h"
3637
#import "Firestore/Source/Util/FSTLogger.h"
3738

3839
#include "Firestore/core/src/firebase/firestore/auth/user.h"
@@ -503,8 +504,13 @@ - (void)processBatchedWatchChanges:(NSArray<FSTWatchChange *> *)changes
503504

504505
// Update in-memory resume tokens. FSTLocalStore will update the persistent view of these when
505506
// applying the completed FSTRemoteEvent.
507+
FSTWeakify(self);
506508
[remoteEvent.targetChanges enumerateKeysAndObjectsUsingBlock:^(
507509
FSTBoxedTargetID *target, FSTTargetChange *change, BOOL *stop) {
510+
FSTStrongify(self);
511+
if (!self) {
512+
return;
513+
}
508514
NSData *resumeToken = change.resumeToken;
509515
if (resumeToken.length > 0) {
510516
FSTQueryData *queryData = self->_listenTargets[target];

Firestore/Source/Util/FSTAsyncQueryListener.mm

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
#import "Firestore/Source/Util/FSTAsyncQueryListener.h"
1818

19+
#import "Firestore/Source/Util/FSTClasses.h"
1920
#import "Firestore/Source/Util/FSTDispatchQueue.h"
2021

2122
@implementation FSTAsyncQueryListener {
@@ -34,8 +35,18 @@ - (instancetype)initWithDispatchQueue:(FSTDispatchQueue *)dispatchQueue
3435
}
3536

3637
- (FSTViewSnapshotHandler)asyncSnapshotHandler {
38+
FSTWeakify(self);
3739
return ^(FSTViewSnapshot *_Nullable snapshot, NSError *_Nullable error) {
40+
FSTStrongify(self);
41+
if (!self) {
42+
return;
43+
}
44+
FSTWeakify(self);
3845
[self->_dispatchQueue dispatchAsync:^{
46+
FSTStrongify(self);
47+
if (!self) {
48+
return;
49+
}
3950
if (!self->_muted) {
4051
self->_snapshotHandler(snapshot, error);
4152
}

0 commit comments

Comments
 (0)