Revision: 29714
http://sourceforge.net/p/bibdesk/svn/29714
Author: hofman
Date: 2025-10-12 16:32:54 +0000 (Sun, 12 Oct 2025)
Log Message:
-----------
update number of connections on local thread with atomic accessor, make sure UI
updating is done on the main thread
Modified Paths:
--------------
trunk/bibdesk/BDSKSharingServer.h
trunk/bibdesk/BDSKSharingServer.m
trunk/bibdesk/BibPref_Sharing.m
Modified: trunk/bibdesk/BDSKSharingServer.h
===================================================================
--- trunk/bibdesk/BDSKSharingServer.h 2025-10-12 16:11:13 UTC (rev 29713)
+++ trunk/bibdesk/BDSKSharingServer.h 2025-10-12 16:32:54 UTC (rev 29714)
@@ -98,7 +98,7 @@
@property (nonatomic, nullable, readonly) NSString *sharingName;
@property (nonatomic, readonly) BDSKSharingStatus status;
-@property (nonatomic, readonly) NSUInteger numberOfConnections;
+@property (readonly) NSUInteger numberOfConnections;
- (void)enableSharing;
- (void)disableSharing;
Modified: trunk/bibdesk/BDSKSharingServer.m
===================================================================
--- trunk/bibdesk/BDSKSharingServer.m 2025-10-12 16:11:13 UTC (rev 29713)
+++ trunk/bibdesk/BDSKSharingServer.m 2025-10-12 16:32:54 UTC (rev 29714)
@@ -148,7 +148,7 @@
@interface BDSKSharingServer ()
@property (nonatomic) BDSKSharingStatus status;
-@property (nonatomic) NSUInteger numberOfConnections;
+@property NSUInteger numberOfConnections;
@end
@@ -595,13 +595,6 @@
#pragma mark Local Thread
-- (void)updateNumberOfConnections {
- NSUInteger count = [registeredClients count];
- dispatch_async(dispatch_get_main_queue(), ^{
- [sharingServer setNumberOfConnections:count];
- });
-}
-
#pragma mark | Async Object
- (void)didSetup
@@ -662,7 +655,6 @@
[connectedClients makeObjectsPerformSelector:@selector(invalidate)];
[connectedClients removeAllObjects];
[registeredClients removeAllObjects];
- [self updateNumberOfConnections];
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
@@ -748,7 +740,7 @@
[clientObject setProtocolForProxy:@protocol(BDSKSharingClient)];
[client setProxy:clientObject];
[registeredClients setObject:client forKey:identifier];
- [self updateNumberOfConnections];
+ [sharingServer setNumberOfConnections:[registeredClients count]];
}
}
@@ -773,7 +765,7 @@
[connectedClients removeObject:client];
[[client connection] invalidate];
}
- [self updateNumberOfConnections];
+ [sharingServer setNumberOfConnections:[registeredClients count]];
}
- (void)notifyClientsOfChange;
Modified: trunk/bibdesk/BibPref_Sharing.m
===================================================================
--- trunk/bibdesk/BibPref_Sharing.m 2025-10-12 16:11:13 UTC (rev 29713)
+++ trunk/bibdesk/BibPref_Sharing.m 2025-10-12 16:32:54 UTC (rev 29714)
@@ -135,10 +135,14 @@
}
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object
change:(NSDictionary<NSKeyValueChangeKey,id> *)change context:(void *)context {
- if (context == &BDSKSharingServerObservationContext)
- [self updateSharingUI];
- else
+ if (context == &BDSKSharingServerObservationContext) {
+ if ([NSThread isMainThread])
+ [self updateSharingUI];
+ else
+ dispatch_async(dispatch_get_main_queue(), ^{ [self
updateSharingUI]; });
+ } else {
[super observeValueForKeyPath:keyPath ofObject:object change:change
context:context];
+ }
}
@end
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
_______________________________________________
Bibdesk-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit