Skip to content

Commit

Permalink
Fixing warning about not being able to invoke some keychain functions…
Browse files Browse the repository at this point in the history
… on the main thread
  • Loading branch information
colincornaby committed Oct 1, 2023
1 parent f3d2ab3 commit 6cbd11e
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions Sources/Plasma/Apps/plClient/Mac-Cocoa/PLSLoginWindowController.mm
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ @interface PLSLoginWindowController ()
#define FAKE_PASS_STRING @"********"

static NSOperationQueue* _loginQueue = nil;
static dispatch_queue_t _keychainQueue = dispatch_queue_create(nullptr, DISPATCH_QUEUE_SERIAL);

@implementation PLSLoginController

Expand Down Expand Up @@ -131,11 +132,13 @@ - (void)save
ST::string username = [self.username STString];
ST::string password = [self.password STString];

pfPasswordStore* store = pfPasswordStore::Instance();
if (self.rememberPassword)
store->SetPassword(username, password);
else
store->SetPassword(username, ST::string());
dispatch_async(_keychainQueue, ^{
pfPasswordStore* store = pfPasswordStore::Instance();
if (self.rememberPassword)
store->SetPassword(username, password);
else
store->SetPassword(username, ST::string());
});
}
}

Expand All @@ -150,8 +153,10 @@ - (void)load
if (self.rememberPassword) {
pfPasswordStore* store = pfPasswordStore::Instance();
ST::string username = [self.username STString];
ST::string password = store->GetPassword(username);
self.password = [NSString stringWithSTString:password];
dispatch_sync(_keychainQueue, ^{
ST::string password = store->GetPassword(username);
self.password = [NSString stringWithSTString:password];
});
}
}

Expand Down

0 comments on commit 6cbd11e

Please sign in to comment.