aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrowanbeentje <rowan@beent.je>2011-08-25 23:50:17 +0000
committerrowanbeentje <rowan@beent.je>2011-08-25 23:50:17 +0000
commitaccb42e79d6f4c968b6219f05d4ffd669ad96fc3 (patch)
tree99db1a4bf3858368453b1df25fee78aea284654b
parent4f35896057fdc7b6e16c55cf4805177c00967f18 (diff)
downloadsequelpro-accb42e79d6f4c968b6219f05d4ffd669ad96fc3.tar.gz
sequelpro-accb42e79d6f4c968b6219f05d4ffd669ad96fc3.tar.bz2
sequelpro-accb42e79d6f4c968b6219f05d4ffd669ad96fc3.zip
- If the field mapper was cancelled, abort the CSV import at once to avoid crashes if a new table name to create was entered
-rw-r--r--Source/SPDataImport.h8
-rw-r--r--Source/SPDataImport.m14
2 files changed, 17 insertions, 5 deletions
diff --git a/Source/SPDataImport.h b/Source/SPDataImport.h
index b9810201..1b668be9 100644
--- a/Source/SPDataImport.h
+++ b/Source/SPDataImport.h
@@ -25,6 +25,12 @@
#import <MCPKit/MCPKit.h>
+typedef enum {
+ SPFieldMapperInProgress = 1,
+ SPFieldMapperCompleted = 2,
+ SPFieldMapperCancelled = 3
+} SPFieldMapperSheetStatus;
+
@class SPFieldMapperController, SPFileHandle;
@interface SPDataImport : NSObject
@@ -89,7 +95,7 @@
NSString *lastFilename;
NSString *csvImportHeaderString;
NSString *csvImportTailString;
- NSInteger fieldMapperSheetStatus;
+ SPFieldMapperSheetStatus fieldMapperSheetStatus;
NSInteger numberOfImportDataColumns;
BOOL fieldMappingArrayHasGlobalVariables;
BOOL csvImportMethodHasTail;
diff --git a/Source/SPDataImport.m b/Source/SPDataImport.m
index e5d7e36c..77e7f676 100644
--- a/Source/SPDataImport.m
+++ b/Source/SPDataImport.m
@@ -1245,7 +1245,7 @@
fieldMappingImportArray = [[NSArray alloc] initWithArray:importData];
numberOfImportDataColumns = [[importData objectAtIndex:0] count];
- fieldMapperSheetStatus = 1;
+ fieldMapperSheetStatus = SPFieldMapperInProgress;
fieldMappingArrayHasGlobalVariables = NO;
// Init the field mapper controller
@@ -1264,9 +1264,15 @@
[[[fieldMapperController window] onMainThread] makeKeyWindow];
// Wait for field mapper sheet
- while (fieldMapperSheetStatus == 1)
+ while (fieldMapperSheetStatus == SPFieldMapperInProgress)
usleep(100000);
+ // If the mapping was cancelled, abort the import
+ if (fieldMapperSheetStatus == SPFieldMapperCancelled) {
+ if (fieldMapperController) [fieldMapperController release];
+ return FALSE;
+ }
+
// Get mapping settings and preset some global variables
fieldMapperOperator = [[NSArray arrayWithArray:[fieldMapperController fieldMapperOperator]] retain];
fieldMappingArray = [[NSArray arrayWithArray:[fieldMapperController fieldMappingArray]] retain];
@@ -1317,7 +1323,7 @@
if(fieldMapperController) [fieldMapperController release];
- if(fieldMapperSheetStatus == 2)
+ if(fieldMapperSheetStatus == SPFieldMapperCompleted)
return YES;
else
return NO;
@@ -1329,7 +1335,7 @@
- (void)fieldMapperDidEndSheet:(NSWindow *)sheet returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo
{
[sheet orderOut:self];
- fieldMapperSheetStatus = (returnCode) ? 2 : 3;
+ fieldMapperSheetStatus = (returnCode) ? SPFieldMapperCompleted : SPFieldMapperCancelled;
}
/**