aboutsummaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2010-08-19 20:28:39 +0000
committerBibiko <bibiko@eva.mpg.de>2010-08-19 20:28:39 +0000
commitfdf2f07d8dfd4260c2dd5dd3326ad7206c1e30f1 (patch)
treef3029d320bf887a3bf360cb7ae8163f447fb26e8 /Source
parent692e6e7330d9a6fd0227f74c1665ddc0b19cc4c6 (diff)
downloadsequelpro-fdf2f07d8dfd4260c2dd5dd3326ad7206c1e30f1.tar.gz
sequelpro-fdf2f07d8dfd4260c2dd5dd3326ad7206c1e30f1.tar.bz2
sequelpro-fdf2f07d8dfd4260c2dd5dd3326ad7206c1e30f1.zip
• made usage of SPBeginWaitingAlertSheet while closing a spf file for readability of that spf file
• suppress if a window with one tab will be closed that [... parentTabShouldClose] method will be called twice via closeTab: - this issue could be the reason for recent crashes/exception esp. of the NSNavigator (should be investigated further)
Diffstat (limited to 'Source')
-rw-r--r--Source/SPAlertSheets.m7
-rw-r--r--Source/SPDatabaseDocument.h2
-rw-r--r--Source/SPDatabaseDocument.m24
-rw-r--r--Source/SPWindowController.m12
4 files changed, 29 insertions, 16 deletions
diff --git a/Source/SPAlertSheets.m b/Source/SPAlertSheets.m
index b16b7c19..bcaea921 100644
--- a/Source/SPAlertSheets.m
+++ b/Source/SPAlertSheets.m
@@ -72,11 +72,10 @@ void SPBeginAlertSheet(
[[docWindow onMainThread] makeKeyWindow];
}
-
/**
- * Provide a simple alias of NSBeginAlertSheet which waits for a in calling class globally
- * declared returnCode by reference which must be changed in the didEndSelector
- * of the calling class, with a few differences:
+ * Provide a simple alias of a NSApp-wide modal NSBeginAlertSheet which waits
+ * for a in calling class globally declared returnCode by reference which must
+ * be changed in the didEndSelector of the calling class, with a few differences:
* - printf-type format strings are no longer supported within the "msg"
* message text argument, preventing access of random stack areas for
* error text which contains inadvertant printf formatting.
diff --git a/Source/SPDatabaseDocument.h b/Source/SPDatabaseDocument.h
index 9d027b4f..28ee97ad 100644
--- a/Source/SPDatabaseDocument.h
+++ b/Source/SPDatabaseDocument.h
@@ -180,6 +180,8 @@
id statusValues;
+ NSInteger saveDocPrefSheetStatus;
+
// Properties
SPWindowController *parentWindowController;
NSWindow *parentWindow;
diff --git a/Source/SPDatabaseDocument.m b/Source/SPDatabaseDocument.m
index a31a9ac7..e99bc702 100644
--- a/Source/SPDatabaseDocument.m
+++ b/Source/SPDatabaseDocument.m
@@ -1077,6 +1077,11 @@
- (void)sheetDidEnd:(id)sheet returnCode:(NSInteger)returnCode contextInfo:(NSString *)contextInfo
{
+ if([contextInfo isEqualToString:@"saveDocPrefSheetStatus"]) {
+ saveDocPrefSheetStatus = returnCode;
+ return;
+ }
+
// Order out current sheet to suppress overlapping of sheets
if ([sheet respondsToSelector:@selector(orderOut:)])
[sheet orderOut:nil];
@@ -3202,16 +3207,19 @@
mutabilityOption:NSPropertyListImmutable format:&format errorDescription:&convError]];
if(!spf || ![spf count] || readError != nil || [convError length] || !(format == NSPropertyListXMLFormat_v1_0 || format == NSPropertyListBinaryFormat_v1_0)) {
- NSAlert *alert = [NSAlert alertWithMessageText:[NSString stringWithFormat:NSLocalizedString(@"Error while reading connection data file", @"error while reading connection data file")]
- defaultButton:NSLocalizedString(@"OK", @"OK button")
- alternateButton:NSLocalizedString(@"Ignore", @"ignore button")
- otherButton:nil
- informativeTextWithFormat:[NSString stringWithFormat:NSLocalizedString(@"Connection data file “%@” couldn't be read. Please try to save the document under a different name.", @"message error while reading connection data file and suggesting to save it under a differnet name"), [fileName lastPathComponent]]];
- [alert setAlertStyle:NSCriticalAlertStyle];
- NSInteger returnCode = [alert runModal];
+ SPBeginWaitingAlertSheet(@"title",
+ NSLocalizedString(@"OK", @"OK button"), NSLocalizedString(@"Ignore", @"ignore button"), nil,
+ NSCriticalAlertStyle, parentWindow, self,
+ @selector(sheetDidEnd:returnCode:contextInfo:),
+ @"saveDocPrefSheetStatus",
+ [NSString stringWithFormat:NSLocalizedString(@"Error while reading connection data file", @"error while reading connection data file")],
+ [NSString stringWithFormat:NSLocalizedString(@"Connection data file “%@” couldn't be read. Please try to save the document under a different name.", @"message error while reading connection data file and suggesting to save it under a differnet name"), [fileName lastPathComponent]],
+ saveDocPrefSheetStatus
+ );
+
if (spf) [spf release];
- if(returnCode == NSAlertAlternateReturn)
+ if(saveDocPrefSheetStatus == NSAlertAlternateReturn)
return YES;
return NO;
diff --git a/Source/SPWindowController.m b/Source/SPWindowController.m
index 65c1c330..33a5ae74 100644
--- a/Source/SPWindowController.m
+++ b/Source/SPWindowController.m
@@ -596,10 +596,14 @@
*/
- (BOOL)windowShouldClose:(id)sender
{
- for (NSTabViewItem *eachItem in [tabView tabViewItems]) {
- SPDatabaseDocument *eachDocument = [eachItem identifier];
- if (![eachDocument parentTabShouldClose]) return NO;
- }
+
+ // Iterate through all tabs if more than one tab is opened only otherwise
+ // [... parentTabShouldClose] will be called twice [see self closeTab:(id)sender]
+ if([[tabView tabViewItems] count] > 1)
+ for (NSTabViewItem *eachItem in [tabView tabViewItems]) {
+ SPDatabaseDocument *eachDocument = [eachItem identifier];
+ if (![eachDocument parentTabShouldClose]) return NO;
+ }
// Remove global session data if the last window of a session will be closed
if([[NSApp delegate] sessionURL] && [[[NSApp delegate] orderedDatabaseConnectionWindows] count] == 1) {