aboutsummaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authormltownsend <mltownsend@gmail.com>2010-05-04 18:25:56 +0000
committermltownsend <mltownsend@gmail.com>2010-05-04 18:25:56 +0000
commit2b23e442dabf3a775e32d6425733badfe4e28785 (patch)
tree24ba9d92baddf2aa00de0aa84294b70c00f56630 /Source
parent08833c0e96eaf3f306bfaf455e8f77cbffc95d5e (diff)
downloadsequelpro-2b23e442dabf3a775e32d6425733badfe4e28785.tar.gz
sequelpro-2b23e442dabf3a775e32d6425733badfe4e28785.tar.bz2
sequelpro-2b23e442dabf3a775e32d6425733badfe4e28785.zip
Fixed crash issue #181 on log.sequelpro.com
Diffstat (limited to 'Source')
-rw-r--r--Source/SPUserManager.m51
1 files changed, 41 insertions, 10 deletions
diff --git a/Source/SPUserManager.m b/Source/SPUserManager.m
index 6594d75f..cb49c084 100644
--- a/Source/SPUserManager.m
+++ b/Source/SPUserManager.m
@@ -1232,7 +1232,41 @@
#pragma mark -
#pragma mark Tab View Delegate methods
+- (BOOL)tabView:(NSTabView *)tabView shouldSelectTabViewItem:(NSTabViewItem *)tabViewItem
+{
+ BOOL retVal = YES;
+ // If there aren't any selected objects, then can't change tab view item
+ if ([[treeController selectedObjects] count] == 0) return NO;
+
+ // Currently selected object in tree
+ id selectedObject = [[treeController selectedObjects] objectAtIndex:0];
+
+ // If we are selecting a tab view that requires there be a child,
+ // make sure there is a child to select. If not, don't allow it.
+ if ([[tabViewItem identifier] isEqualToString:@"Global Privileges"]
+ || [[tabViewItem identifier] isEqualToString:@"Resources"]
+ || [[tabViewItem identifier] isEqualToString:@"Schema Privileges"]) {
+ id parent = [selectedObject parent];
+ if (parent) {
+ retVal = ([[parent children] count] > 0);
+ } else {
+ retVal = ([[selectedObject children] count] > 0);
+ }
+ if (retVal == NO) {
+ NSAlert *alert = [NSAlert alertWithMessageText:@"User doesn't have any hosts."
+ defaultButton:@"Add Host"
+ alternateButton:NSLocalizedString(@"Cancel", @"cancel button")
+ otherButton:nil
+ informativeTextWithFormat:@"This user doesn't have any hosts associated with it. User will be deleted unless one is added"];
+ NSInteger ret = [alert runModal];
+ if (ret == NSAlertDefaultReturn) {
+ [self addHost:nil];
+ }
+ }
+ }
+ return retVal;
+}
-(void)tabView:(NSTabView *)tabView didSelectTabViewItem:(NSTabViewItem *)tabViewItem
{
if ([[treeController selectedObjects] count] == 0) return;
@@ -1255,6 +1289,13 @@
}
}
+- (void)tabView:(NSTabView *)usersTabView willSelectTabViewItem:(NSTabViewItem *)tabViewItem
+{
+ if ([[tabViewItem identifier] isEqualToString:@"Schema Privileges"]) {
+ [self _initializeSchemaPrivs];
+ }
+}
+
#pragma mark -
#pragma mark SplitView delegate methods
@@ -1347,16 +1388,6 @@
}
#pragma mark -
-#pragma mark Tab view delegate methods
-
-- (void)tabView:(NSTabView *)usersTabView willSelectTabViewItem:(NSTabViewItem *)tabViewItem
-{
- if ([[tabViewItem identifier] isEqualToString:@"Schema Privileges"]) {
- [self _initializeSchemaPrivs];
- }
-}
-
-#pragma mark -
/**
* Dealloc. Get rid of everything.