diff --git a/Limelight/Database/TemporaryHost.h b/Limelight/Database/TemporaryHost.h index 92d2b5b..f3c39e3 100644 --- a/Limelight/Database/TemporaryHost.h +++ b/Limelight/Database/TemporaryHost.h @@ -11,24 +11,24 @@ @interface TemporaryHost : NSObject -@property (nonatomic) State state; -@property (nonatomic) PairState pairState; -@property (nonatomic, nullable) NSString * activeAddress; -@property (nonatomic, nullable) NSString * currentGame; +@property (atomic) State state; +@property (atomic) PairState pairState; +@property (atomic, nullable, retain) NSString * activeAddress; +@property (atomic, nullable, retain) NSString * currentGame; -@property (nonatomic, nullable, retain) NSData *serverCert; -@property (nonatomic, nullable, retain) NSString *address; -@property (nonatomic, nullable, retain) NSString *externalAddress; -@property (nonatomic, nullable, retain) NSString *localAddress; -@property (nonatomic, nullable, retain) NSString *ipv6Address; -@property (nonatomic, nullable, retain) NSString *mac; -@property (nonatomic) int serverCodecModeSupport; +@property (atomic, nullable, retain) NSData *serverCert; +@property (atomic, nullable, retain) NSString *address; +@property (atomic, nullable, retain) NSString *externalAddress; +@property (atomic, nullable, retain) NSString *localAddress; +@property (atomic, nullable, retain) NSString *ipv6Address; +@property (atomic, nullable, retain) NSString *mac; +@property (atomic) int serverCodecModeSupport; NS_ASSUME_NONNULL_BEGIN -@property (nonatomic, retain) NSString *name; -@property (nonatomic, retain) NSString *uuid; -@property (nonatomic, retain) NSMutableSet *appList; +@property (atomic, retain) NSString *name; +@property (atomic, retain) NSString *uuid; +@property (atomic, retain) NSSet *appList; - (id) initFromHost:(Host*)host; diff --git a/Limelight/ViewControllers/MainFrameViewController.m b/Limelight/ViewControllers/MainFrameViewController.m index d295d8e..754d6ec 100644 --- a/Limelight/ViewControllers/MainFrameViewController.m +++ b/Limelight/ViewControllers/MainFrameViewController.m @@ -192,10 +192,11 @@ static NSMutableSet* hostList; - (void) updateApplist:(NSSet*) newList forHost:(TemporaryHost*)host { DataManager* database = [[DataManager alloc] init]; + NSMutableSet* newHostAppList = [NSMutableSet setWithSet:host.appList]; for (TemporaryApp* app in newList) { BOOL appAlreadyInList = NO; - for (TemporaryApp* savedApp in host.appList) { + for (TemporaryApp* savedApp in newHostAppList) { if ([app.id isEqualToString:savedApp.id]) { savedApp.name = app.name; savedApp.hdrSupported = app.hdrSupported; @@ -205,7 +206,7 @@ static NSMutableSet* hostList; } if (!appAlreadyInList) { app.host = host; - [host.appList addObject:app]; + [newHostAppList addObject:app]; } } @@ -213,7 +214,7 @@ static NSMutableSet* hostList; do { appWasRemoved = NO; - for (TemporaryApp* app in host.appList) { + for (TemporaryApp* app in newHostAppList) { appWasRemoved = YES; for (TemporaryApp* mergedApp in newList) { if ([mergedApp.id isEqualToString:app.id]) { @@ -225,7 +226,7 @@ static NSMutableSet* hostList; // Removing the app mutates the list we're iterating (which isn't legal). // We need to jump out of this loop and restart enumeration. - [host.appList removeObject:app]; + [newHostAppList removeObject:app]; // It's important to remove the app record from the database // since we'll have a constraint violation now that appList @@ -238,6 +239,8 @@ static NSMutableSet* hostList; // Keep looping until the list is no longer being mutated } while (appWasRemoved); + + host.appList = newHostAppList; [database updateAppsForExistingHost:host];