aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormltownsend <mltownsend@gmail.com>2010-05-28 21:18:13 +0000
committermltownsend <mltownsend@gmail.com>2010-05-28 21:18:13 +0000
commitfa3e5de72829b2458c6966b1cad3c99d62401a49 (patch)
tree037d33f131bb15077a24972553af463c18f4dc07
parent8c545d7dfd8bea5f1776395826297ae2c6cb1433 (diff)
downloadsequelpro-fa3e5de72829b2458c6966b1cad3c99d62401a49.tar.gz
sequelpro-fa3e5de72829b2458c6966b1cad3c99d62401a49.tar.bz2
sequelpro-fa3e5de72829b2458c6966b1cad3c99d62401a49.zip
Changed the refresh method so that it creates a new persistentstore as well and clearing out the outlineview.
-rw-r--r--Source/SPUserManager.h4
-rw-r--r--Source/SPUserManager.m29
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)