diff options
Diffstat (limited to 'Source')
-rw-r--r-- | Source/SPAppController.m | 31 | ||||
-rw-r--r-- | Source/SPDatabaseDocument.h | 2 | ||||
-rw-r--r-- | Source/SPDatabaseDocument.m | 17 |
3 files changed, 23 insertions, 27 deletions
diff --git a/Source/SPAppController.m b/Source/SPAppController.m index ca5887c9..fa9dbc4a 100644 --- a/Source/SPAppController.m +++ b/Source/SPAppController.m @@ -134,6 +134,15 @@ YY_BUFFER_STATE yy_scan_string (const char *); [self reloadBundles:self]; + // If no documents are open, open one + if (![self frontDocument]) { + [self newWindow:self]; + + // Set autoconnection if appropriate + if ([[NSUserDefaults standardUserDefaults] boolForKey:SPAutoConnectToDefault]) { + [[self frontDocument] connect]; + } + } } /** @@ -447,7 +456,9 @@ YY_BUFFER_STATE yy_scan_string (const char *); [newWindowController addNewConnection:self]; [[self frontDocument] setIsSavedInBundle:isBundleFile]; - [[self frontDocument] setStateFromConnectionFile:fileName]; + if (![[self frontDocument] setStateFromConnectionFile:fileName]) { + break; + } } } else { @@ -2083,24 +2094,6 @@ YY_BUFFER_STATE yy_scan_string (const char *); #pragma mark Other methods /** - * Override the default open-blank-document methods to automatically connect automatically opened windows - * if the preference is set - */ -- (BOOL)applicationShouldOpenUntitledFile:(NSApplication *)sender -{ - // Manually open a table document - [self newWindow:self]; - - // Set autoconnection if appropriate - if ([[NSUserDefaults standardUserDefaults] boolForKey:SPAutoConnectToDefault]) { - [[self frontDocument] connect]; - } - - // Return NO to the automatic opening - return NO; -} - -/** * Implement this method to prevent the above being called in the case of a reopen (for example, clicking * the dock icon) where we don't want the auto-connect to kick in. */ diff --git a/Source/SPDatabaseDocument.h b/Source/SPDatabaseDocument.h index b1d19600..9c7111ad 100644 --- a/Source/SPDatabaseDocument.h +++ b/Source/SPDatabaseDocument.h @@ -456,7 +456,7 @@ SPDatabaseData, SPTablesList, SPTableStructure, SPTableContent, SPTableData, SPS // State saving and setting - (NSDictionary *)stateIncludingDetails:(NSDictionary *)detailsToReturn; - (BOOL)setState:(NSDictionary *)stateDetails; -- (void)setStateFromConnectionFile:(NSString *)path; +- (BOOL)setStateFromConnectionFile:(NSString *)path; - (void)restoreSession; #endif diff --git a/Source/SPDatabaseDocument.m b/Source/SPDatabaseDocument.m index 7c7d2a39..a6d7bfd8 100644 --- a/Source/SPDatabaseDocument.m +++ b/Source/SPDatabaseDocument.m @@ -4509,8 +4509,9 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; /** * Initialise the document with the connection file at the supplied path. + * Returns whether the document was initialised successfully. */ -- (void)setStateFromConnectionFile:(NSString *)path +- (BOOL)setStateFromConnectionFile:(NSString *)path { NSError *readError = nil; NSString *convError = nil; @@ -4538,7 +4539,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; [alert runModal]; if (spf) [spf release]; [self closeAndDisconnect]; - return; + return NO; } // If the .spf format is unhandled, error. @@ -4553,7 +4554,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; [spf release]; [self closeAndDisconnect]; [alert runModal]; - return; + return NO; } // Error if the expected data source wasn't present in the file @@ -4568,7 +4569,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; [alert runModal]; [spf release]; [self closeAndDisconnect]; - return; + return NO; } // Ask for a password if SPF file passwords were encrypted, via a sheet @@ -4616,7 +4617,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; } else { [self closeAndDisconnect]; [spf release]; - return; + return NO; } } } @@ -4642,7 +4643,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; [alert runModal]; [self closeAndDisconnect]; [spf release]; - return; + return NO; } } @@ -4664,7 +4665,7 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; [alert runModal]; [self closeAndDisconnect]; [spf release]; - return; + return NO; } // Move favourites and history into the data dictionary to pass to setState: @@ -4702,6 +4703,8 @@ static NSString *SPRenameDatabaseAction = @"SPRenameDatabase"; [self setState:data]; [spf release]; + + return YES; } /** |