Skip to content

Commit 386416e

Browse files
authored
CBL-6813: Deprecate removeChangeListenerWithToken for Replicator and Query APIs (#3447)
1 parent d3d4dfc commit 386416e

25 files changed

+46
-114
lines changed

Objective-C/CBLQuery.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,8 @@ NS_ASSUME_NONNULL_BEGIN
9898
9999
@param token The listener token.
100100
*/
101-
- (void) removeChangeListenerWithToken: (id<CBLListenerToken>)token;
101+
- (void) removeChangeListenerWithToken: (id<CBLListenerToken>)token
102+
__deprecated_msg("Use [ListenerToken remove] instead.");
102103

103104

104105
/** Not available */

Objective-C/CBLQuery.mm

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,13 @@ - (void) removeChangeListenerWithToken: (id<CBLListenerToken>)token {
309309
#pragma mark delegate(CBLRemovableListenerToken)
310310

311311
- (void) removeToken: (id)token {
312-
[self removeChangeListenerWithToken: token];
312+
CBLAssertNotNil(token);
313+
314+
CBL_LOCK(self) {
315+
CBLChangeListenerToken* t = (CBLChangeListenerToken*)token;
316+
[(CBLQueryObserver*)t.context stop];
317+
[_changeNotifier removeChangeListenerWithToken: token];
318+
}
313319
}
314320

315321
#pragma mark - Internal

Objective-C/CBLReplicator.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,8 @@ the replicator change notification.
135135
136136
@param token The listener token;
137137
*/
138-
- (void) removeChangeListenerWithToken: (id<CBLListenerToken>)token;
138+
- (void) removeChangeListenerWithToken: (id<CBLListenerToken>)token
139+
__deprecated_msg("Use [ListenerToken remove] instead.");
139140

140141
/**
141142
Get pending document ids for default collection. If the default collection is not part of the

Objective-C/CBLReplicator.mm

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,12 @@ - (void) removeChangeListenerWithToken: (id<CBLListenerToken>)token {
492492
#pragma mark delegate(CBLRemovableListenerToken)
493493

494494
- (void) removeToken: (id)token {
495-
[self removeChangeListenerWithToken: token];
495+
[_changeNotifier removeChangeListenerWithToken: token];
496+
497+
CBL_LOCK(self) {
498+
if ([_docReplicationNotifier removeChangeListenerWithToken: token] == 0)
499+
[self setProgressLevel: kCBLProgressLevelOverall];
500+
}
496501
}
497502

498503
- (void) setProgressLevel: (CBLReplicatorProgressLevel)level {

Objective-C/Internal/Replicator/CBLReplicator+Backgrounding.m

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,8 @@ - (void) startBackgroundingMonitor {
5656
}
5757

5858
- (NSFileProtectionType) fileProtection {
59-
// TODO: Remove https://issues.couchbase.com/browse/CBL-3206
60-
#pragma clang diagnostic push
61-
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
6259
NSDictionary* attrs = [NSFileManager.defaultManager attributesOfItemAtPath: self.config.database.path error: NULL];
6360
return attrs[NSFileProtectionKey] ?: NSFileProtectionNone;
64-
#pragma clang diagnostic pop
6561
}
6662

6763
- (void) endBackgroundingMonitor {

Objective-C/Tests/ArrayTest.m

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,6 @@ @interface ArrayTest : CBLTestCase
3030

3131
@implementation ArrayTest
3232

33-
// TODO: Remove https://issues.couchbase.com/browse/CBL-3206
34-
#pragma clang diagnostic push
35-
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
36-
3733
- (NSArray*) arrayOfAllTypes {
3834
NSMutableArray* array = [NSMutableArray array];
3935
[array addObject: @(YES)];
@@ -1106,6 +1102,4 @@ - (void) testGetBlobContentFromMutableObject {
11061102
AssertNotNil(blob.content);
11071103
}
11081104

1109-
#pragma clang diagnostic pop
1110-
11111105
@end

Objective-C/Tests/CBLTestCase.m

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,6 @@ @implementation CBLTestCase
3737

3838
@synthesize db=_db, otherDB=_otherDB, disableObjectLeakCheck=_disableObjectLeakCheck;
3939

40-
// TODO: Remove https://issues.couchbase.com/browse/CBL-3206
41-
#pragma clang diagnostic push
42-
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
43-
4440
- (XCTestExpectation*) allowOverfillExpectationWithDescription:(NSString *)description {
4541
XCTestExpectation* e = [super expectationWithDescription: description];
4642
e.assertForOverFulfill = false;
@@ -483,6 +479,4 @@ - (NSString*) getRickAndMortyJSON {
483479
return [self stringFromResource: @"rick_morty" ofType: @"json"];
484480
}
485481

486-
#pragma clang diagnostic pop
487-
488482
@end

Objective-C/Tests/DocumentTest.m

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,6 @@ @interface DocumentTest : CBLTestCase
3333

3434
@implementation DocumentTest
3535

36-
// TODO: Remove https://issues.couchbase.com/browse/CBL-3206
37-
#pragma clang diagnostic push
38-
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
39-
4036
- (void) populateData: (CBLMutableDocument*)doc {
4137
[doc setValue: @(YES) forKey: @"true"];
4238
[doc setValue: @(NO) forKey: @"false"];
@@ -2381,6 +2377,4 @@ - (void) testDocumentRevisionHistory {
23812377
Assert(doc._getRevisionHistory);
23822378
}
23832379

2384-
#pragma clang diagnostic pop
2385-
23862380
@end

Objective-C/Tests/FragmentTest.m

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,6 @@ @interface FragmentTest : CBLTestCase
2525

2626
@implementation FragmentTest
2727

28-
// TODO: Remove https://issues.couchbase.com/browse/CBL-3206
29-
#pragma clang diagnostic push
30-
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
31-
3228
- (void) testBasicGetFragmentValues {
3329
CBLMutableDocument* doc = [self createDocument: @"doc1"];
3430
[doc setData: @{ @"name": @"Jason",
@@ -682,6 +678,4 @@ - (void) testOutOfRangeArrayFragmentSetObject {
682678
}];
683679
}
684680

685-
#pragma clang diagnostic pop
686-
687681
@end

Objective-C/Tests/PredicateQueryTest.m

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,6 @@ @interface PredicateQueryTest : CBLTestCase
3030

3131
@implementation PredicateQueryTest
3232

33-
// TODO: Remove https://issues.couchbase.com/browse/CBL-3206
34-
#pragma clang diagnostic push
35-
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
36-
3733
- (CBLDocument*) docForRow: (CBLQueryRow*)row {
3834
NSString* docID = [row stringAtIndex: 0];
3935
C4SequenceNumber sequence = [row integerAtIndex: 1];
@@ -415,6 +411,4 @@ - (void) testWhereIn {
415411
AssertEqual((int)numRows, (int)expected.count);
416412
}
417413

418-
#pragma clang diagnostic pop
419-
420414
@end

0 commit comments

Comments
 (0)