diff options
-rw-r--r-- | Source/SPUserManager.h | 4 | ||||
-rw-r--r-- | Source/SPUserManager.m | 29 |
2 files changed, 19 insertions, 14 deletions
diff --git a/Source/SPUserManager.h b/Source/SPUserManager.h index aa6cce76..97ed03a4 100644 --- a/Source/SPUserManager.h +++ b/Source/SPUserManager.h @@ -66,9 +66,9 @@ } @property (nonatomic, retain) MCPConnection *mySqlConnection; -@property (nonatomic, retain, readonly) NSPersistentStoreCoordinator *persistentStoreCoordinator; +@property (nonatomic, retain) NSPersistentStoreCoordinator *persistentStoreCoordinator; @property (nonatomic, retain, readonly) NSManagedObjectModel *managedObjectModel; -@property (nonatomic, retain, readonly) NSManagedObjectContext *managedObjectContext; +@property (nonatomic, retain) NSManagedObjectContext *managedObjectContext; @property (nonatomic, retain) NSMutableDictionary *privsSupportedByServer; @property (nonatomic, retain) NSArray *treeSortDescriptors; diff --git a/Source/SPUserManager.m b/Source/SPUserManager.m index 48446d22..e6809921 100644 --- a/Source/SPUserManager.m +++ b/Source/SPUserManager.m @@ -756,18 +756,28 @@ return; } } - NSSet *registeredObjects = [managedObjectContext registeredObjects]; - for (NSManagedObject *registeredObject in registeredObjects) - { - [self.managedObjectContext refreshObject:registeredObject mergeChanges:NO]; - } [self.managedObjectContext reset]; [grantedSchemaPrivs removeAllObjects]; - //[grantedController fetch:nil]; [grantedTableView reloadData]; [self _initializeAvailablePrivs]; - [treeController fetch:nil]; + [outlineView reloadData]; + [treeController rearrangeObjects]; + + // Get all the stores on the current MOC and remove them. + NSArray *stores = [[self.managedObjectContext persistentStoreCoordinator] persistentStores]; + for(NSPersistentStore* store in stores) + { + NSError *error = nil; + [[self.managedObjectContext persistentStoreCoordinator] removePersistentStore:store error:error]; + } + // Add a new store + NSError *error = nil; + [[self.managedObjectContext persistentStoreCoordinator] + addPersistentStoreWithType:NSInMemoryStoreType configuration:nil URL:nil options:nil error:&error]; + + // Reinitialize the tree with values from the database. + [self _initializeUsers]; // After the reset, ensure all original password and user values are up-to-date. NSEntityDescription *entityDescription = [NSEntityDescription entityForName:@"SPUser" @@ -928,11 +938,6 @@ if (!isInitializing) [outlineView reloadData]; } -- (void)userManagerSheetDidEnd:(NSWindow *)sheet returnCode:(int)returnCode contextInfo:(void*)context -{ - [self refresh:nil]; -} - - (BOOL)updateUsers:(NSArray *)updatedUsers { for (NSManagedObject *user in updatedUsers) |