Skip to content

Commit

Permalink
Fix getting app delegate from background thread
Browse files Browse the repository at this point in the history
  • Loading branch information
hjuutilainen committed Aug 26, 2019
1 parent 125371c commit ebf56a1
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion MunkiAdmin/NSOperation Subclasses/MAManifestScanner.m
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ - (void)scan {
@try {
@autoreleasepool {

MAMunkiAdmin_AppDelegate *appDelegate = (MAMunkiAdmin_AppDelegate *)[NSApp delegate];
MAMunkiAdmin_AppDelegate *appDelegate = (MAMunkiAdmin_AppDelegate *)self.delegate;
NSManagedObjectContext *privateContext = self.context;
self.currentJobDescription = [NSString stringWithFormat:@"Reading manifest %@", self.fileName];

Expand Down
2 changes: 1 addition & 1 deletion MunkiAdmin/NSOperation Subclasses/MAPkginfoScanner.m
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ - (void)scan

MAMunkiRepositoryManager *repoManager = [MAMunkiRepositoryManager sharedManager];
MACoreDataManager *coreDataManager = [MACoreDataManager sharedManager];
MAMunkiAdmin_AppDelegate *appDelegate = (MAMunkiAdmin_AppDelegate *)[NSApp delegate];

MAMunkiAdmin_AppDelegate *appDelegate = (MAMunkiAdmin_AppDelegate *)self.delegate;
NSManagedObjectContext *privateContext = self.context;

NSEntityDescription *catalogEntityDescr = [NSEntityDescription entityForName:@"Catalog" inManagedObjectContext:privateContext];
Expand Down
4 changes: 2 additions & 2 deletions MunkiAdmin/NSOperation Subclasses/MARelationshipScanner.m
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ - (void)scanManifests

- (void)scanPkginfos
{
MAMunkiAdmin_AppDelegate *appDelegate = (MAMunkiAdmin_AppDelegate *)[NSApp delegate];
MAMunkiAdmin_AppDelegate *appDelegate = (MAMunkiAdmin_AppDelegate *)self.delegate;
NSManagedObjectContext *privateContext = self.context;

NSEntityDescription *catalogEntityDescr = [NSEntityDescription entityForName:@"Catalog" inManagedObjectContext:privateContext];
Expand Down Expand Up @@ -666,7 +666,7 @@ use a default icon (which is the icon for .pkg file type).

- (void)main {
self.context = [[NSManagedObjectContext alloc] initWithConcurrencyType:NSPrivateQueueConcurrencyType];
self.context.parentContext = [(MAMunkiAdmin_AppDelegate *)[NSApp delegate] managedObjectContext];
self.context.parentContext = [(MAMunkiAdmin_AppDelegate *)self.delegate managedObjectContext];
self.context.undoManager = nil;
[self.context performBlockAndWait:^{
@try {
Expand Down
2 changes: 2 additions & 0 deletions MunkiAdmin/Singletons/MAMunkiRepositoryManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -770,6 +770,7 @@ - (BOOL)duplicateManifest:(ManifestMO *)manifest
Scan the new item
*/
MAManifestScanner *manifestScanner = [[MAManifestScanner alloc] initWithURL:newURL];
manifestScanner.delegate = [NSApp delegate];
manifestScanner.performFullScan = YES;
[manifestScanner start];
succeeded = YES;
Expand Down Expand Up @@ -804,6 +805,7 @@ - (BOOL)duplicateManifest:(ManifestMO *)manifest toURL:(NSURL *)newURL
Scan the new item
*/
MAManifestScanner *manifestScanner = [[MAManifestScanner alloc] initWithURL:newURL];
manifestScanner.delegate = [NSApp delegate];
manifestScanner.performFullScan = YES;
[manifestScanner start];
succeeded = YES;
Expand Down

0 comments on commit ebf56a1

Please sign in to comment.