diff options
author | Max <post@wickenrode.com> | 2014-12-14 17:19:50 +0100 |
---|---|---|
committer | Max <post@wickenrode.com> | 2014-12-14 17:19:50 +0100 |
commit | 915b4fb171afec486a386b7098f6ccfe59058f4f (patch) | |
tree | b6880a6790988364e3903d0d5114ff5894704649 | |
parent | c573bf18ff0ce2a350bec687f2d7cc5ba5a69865 (diff) | |
download | sequelpro-915b4fb171afec486a386b7098f6ccfe59058f4f.tar.gz sequelpro-915b4fb171afec486a386b7098f6ccfe59058f4f.tar.bz2 sequelpro-915b4fb171afec486a386b7098f6ccfe59058f4f.zip |
Fix crash on export with "overwrite existing files"
This should fix #2010. A required object was not retained long enough.
-rw-r--r-- | Source/SPExportFileUtilities.m | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/Source/SPExportFileUtilities.m b/Source/SPExportFileUtilities.m index aafea54d..778deb3e 100644 --- a/Source/SPExportFileUtilities.m +++ b/Source/SPExportFileUtilities.m @@ -31,10 +31,11 @@ #import "SPExportFileUtilities.h" #import "SPExportInitializer.h" #import "SPExporter.h" -#import "SPAlertSheets.h" #import "SPExportFile.h" #import "SPDatabaseDocument.h" #import "SPCustomQuery.h" +#import "SPTableContent.h" +#import "SPTableContentDelegate.h" #import <SPMySQL/SPMySQL.h> @@ -53,7 +54,7 @@ SPExportErrorChoice; @end -@implementation SPExportController (SPExportFileUtilities) +@implementation SPExportController (SPExportFileUtilitiesPrivateAPI) /** * Writes the CSV file header to the supplied export file. @@ -115,7 +116,7 @@ SPExportErrorChoice; if ([exportXMLFormatPopUpButton indexOfSelectedItem] == SPXMLExportMySQLFormat) { - NSString *tag = @""; + NSString *tag; if (exportSource == SPTableExport) { tag = [NSString stringWithFormat:@"<mysqldump xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n<database name=\"%@\">\n\n", [tableDocumentInstance database]]; @@ -141,6 +142,11 @@ SPExportErrorChoice; */ - (void)errorCreatingExportFileHandles:(NSArray *)files { + // We don't know where "files" came from, but we know 2 things: + // - NSAlert will NOT retain it as contextInfo + // - This method continues execution after [alert beginSheet:...], thus even if files was retained before, it could be released before the alert ends + [files retain]; + // Get the number of files that already exist as well as couldn't be created because of other reasons NSUInteger filesAlreadyExisting = 0; NSUInteger parentFoldersMissing = 0; @@ -270,6 +276,7 @@ SPExportErrorChoice; [exportProgressWindow orderOut:self]; [alert beginSheetModalForWindow:[tableDocumentInstance parentWindow] modalDelegate:self didEndSelector:@selector(alertDidEnd:returnCode:contextInfo:) contextInfo:files]; + [alert autorelease]; } /** |