diff --git a/External/Pearl b/External/Pearl index 1a1ab801..b889e631 160000 --- a/External/Pearl +++ b/External/Pearl @@ -1 +1 @@ -Subproject commit 1a1ab801f1dbfe7266f1db6ad4359e85ed3c0eb4 +Subproject commit b889e6312d5ecd9d2e45eb1402cadc6e27ed84c4 diff --git a/MasterPassword/ObjC/MPAppDelegate_Shared.m b/MasterPassword/ObjC/MPAppDelegate_Shared.m index 0b6f9b54..5527f611 100644 --- a/MasterPassword/ObjC/MPAppDelegate_Shared.m +++ b/MasterPassword/ObjC/MPAppDelegate_Shared.m @@ -44,6 +44,10 @@ - (void)setActiveUser:(MPUserEntity *)activeUser { + NSError *error; + if (activeUser.objectID.isTemporaryID && ![activeUser.managedObjectContext obtainPermanentIDsForObjects:@[ activeUser ] error:&error]) + err(@"Failed to obtain a permanent object ID after setting active user: %@", error); + _activeUserOID = activeUser.objectID; } diff --git a/MasterPassword/ObjC/iOS/MPElementListController.m b/MasterPassword/ObjC/iOS/MPElementListController.m index 6377c543..641c4362 100644 --- a/MasterPassword/ObjC/iOS/MPElementListController.m +++ b/MasterPassword/ObjC/iOS/MPElementListController.m @@ -145,9 +145,9 @@ NSError *error; self.fetchedResultsControllerByLastUsed.fetchRequest.predicate = predicate; self.fetchedResultsControllerByUses.fetchRequest.predicate = predicate; - if (![self.fetchedResultsControllerByLastUsed performFetch:&error]) + if (self.fetchedResultsControllerByLastUsed && ![self.fetchedResultsControllerByLastUsed performFetch:&error]) err(@"Couldn't fetch elements: %@", error); - if (![self.fetchedResultsControllerByUses performFetch:&error]) + if (self.fetchedResultsControllerByUses && ![self.fetchedResultsControllerByUses performFetch:&error]) err(@"Couldn't fetch elements: %@", error); [self.tableView reloadData]; @@ -157,50 +157,46 @@ } // See MP-14, also crashes easily on internal assertions etc.. -- (void)controllerWillChangeContent:(NSFetchedResultsController *)controller { - - dbg(@"%@", NSStringFromSelector( _cmd )); - [self.tableView beginUpdates]; -} - -- (void)controller:(NSFetchedResultsController *)controller didChangeObject:(id)anObject - atIndexPath:(NSIndexPath *)indexPath forChangeType:(NSFetchedResultsChangeType)type newIndexPath:(NSIndexPath *)newIndexPath { - - switch (type) { - - case NSFetchedResultsChangeInsert: - dbg(@"%@ -- NSFetchedResultsChangeInsert:%@", NSStringFromSelector( _cmd ), anObject); - [self.tableView insertRowsAtIndexPaths:@[ [self tableIndexPathForFetchController:controller indexPath:newIndexPath] ] - withRowAnimation:UITableViewRowAnimationAutomatic]; - break; - - case NSFetchedResultsChangeDelete: - dbg(@"%@ -- NSFetchedResultsChangeDelete:%@", NSStringFromSelector( _cmd ), anObject); - [self.tableView deleteRowsAtIndexPaths:@[ [self tableIndexPathForFetchController:controller indexPath:indexPath] ] - withRowAnimation:UITableViewRowAnimationAutomatic]; - break; - - case NSFetchedResultsChangeUpdate: - dbg(@"%@ -- NSFetchedResultsChangeUpdate:%@", NSStringFromSelector( _cmd ), anObject); - [self.tableView reloadRowsAtIndexPaths:@[ [self tableIndexPathForFetchController:controller indexPath:indexPath] ] - withRowAnimation:UITableViewRowAnimationAutomatic]; - break; - - case NSFetchedResultsChangeMove: - dbg(@"%@ -- NSFetchedResultsChangeMove:%@", NSStringFromSelector( _cmd ), anObject); - [self.tableView deleteRowsAtIndexPaths:@[ [self tableIndexPathForFetchController:controller indexPath:indexPath] ] - withRowAnimation:UITableViewRowAnimationAutomatic]; - [self.tableView insertRowsAtIndexPaths:@[ [self tableIndexPathForFetchController:controller indexPath:newIndexPath] ] - withRowAnimation:UITableViewRowAnimationAutomatic]; - break; - } -} +//- (void)controllerWillChangeContent:(NSFetchedResultsController *)controller { +// +// [self.tableView beginUpdates]; +//} +// +//- (void)controller:(NSFetchedResultsController *)controller didChangeObject:(id)anObject +// atIndexPath:(NSIndexPath *)indexPath forChangeType:(NSFetchedResultsChangeType)type newIndexPath:(NSIndexPath *)newIndexPath { +// +// switch (type) { +// +// case NSFetchedResultsChangeInsert: +// [self.tableView insertRowsAtIndexPaths:@[ [self tableIndexPathForFetchController:controller indexPath:newIndexPath] ] +// withRowAnimation:UITableViewRowAnimationAutomatic]; +// break; +// +// case NSFetchedResultsChangeDelete: +// [self.tableView deleteRowsAtIndexPaths:@[ [self tableIndexPathForFetchController:controller indexPath:indexPath] ] +// withRowAnimation:UITableViewRowAnimationAutomatic]; +// break; +// +// case NSFetchedResultsChangeUpdate: +// [self.tableView reloadRowsAtIndexPaths:@[ [self tableIndexPathForFetchController:controller indexPath:indexPath] ] +// withRowAnimation:UITableViewRowAnimationAutomatic]; +// break; +// +// case NSFetchedResultsChangeMove: +// [self.tableView deleteRowsAtIndexPaths:@[ [self tableIndexPathForFetchController:controller indexPath:indexPath] ] +// withRowAnimation:UITableViewRowAnimationAutomatic]; +// [self.tableView insertRowsAtIndexPaths:@[ [self tableIndexPathForFetchController:controller indexPath:newIndexPath] ] +// withRowAnimation:UITableViewRowAnimationAutomatic]; +// break; +// } +//} - (void)controllerDidChangeContent:(NSFetchedResultsController *)controller { - dbg(@"%@ on %@", NSStringFromSelector( _cmd ), [NSThread currentThread].name); - [self customTableViewUpdates]; - [self.tableView endUpdates]; +// [self customTableViewUpdates]; +// [self.tableView endUpdates]; + + [self.tableView reloadData]; } - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { diff --git a/MasterPassword/ObjC/iOS/MPMainViewController.m b/MasterPassword/ObjC/iOS/MPMainViewController.m index f4d042e1..eeb3dcd3 100644 --- a/MasterPassword/ObjC/iOS/MPMainViewController.m +++ b/MasterPassword/ObjC/iOS/MPMainViewController.m @@ -799,6 +799,12 @@ newElement.loginName = activeElement.loginName; [activeElement.managedObjectContext deleteObject:activeElement]; + + NSError *error; + if (![newElement.managedObjectContext obtainPermanentIDsForObjects:@[ newElement ] + error:&error]) + err(@"Failed to obtain a permanent object ID after changing object type: %@", error); + _activeElementOID = newElement.objectID; activeElement = newElement; } @@ -813,6 +819,10 @@ - (void)didSelectElement:(MPElementEntity *)element { inf(@"Selected: %@", element.name); + NSError *error = nil; + if (element.objectID.isTemporaryID && ![element.managedObjectContext obtainPermanentIDsForObjects:@[ element ] error:&error]) + err(@"Failed to obtain a permanent object ID after setting active element: %@", error); + _activeElementOID = element.objectID; [self closeAlert]; diff --git a/MasterPassword/ObjC/iOS/MPUnlockViewController.m b/MasterPassword/ObjC/iOS/MPUnlockViewController.m index 1831c705..c1b3ce03 100644 --- a/MasterPassword/ObjC/iOS/MPUnlockViewController.m +++ b/MasterPassword/ObjC/iOS/MPUnlockViewController.m @@ -1139,6 +1139,11 @@ - (void)setSelectedUser:(MPUserEntity *)selectedUser { + NSError *error = nil; + if (selectedUser.objectID.isTemporaryID && + ![selectedUser.managedObjectContext obtainPermanentIDsForObjects:@[ selectedUser ] error:&error]) + err(@"Failed to obtain a permanent object ID after setting selected user: %@", error); + _selectedUserOID = selectedUser.objectID; }