aboutsummaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
Diffstat (limited to 'Source')
-rw-r--r--Source/CMMCPResult.h1
-rw-r--r--Source/CMMCPResult.m4
-rw-r--r--Source/CustomQuery.m8
-rw-r--r--Source/TableContent.h4
-rw-r--r--Source/TableContent.m139
-rw-r--r--Source/TableDocument.m26
-rw-r--r--Source/TableDump.m4
-rw-r--r--Source/TablesList.m6
8 files changed, 140 insertions, 52 deletions
diff --git a/Source/CMMCPResult.h b/Source/CMMCPResult.h
index 7f527949..d460b361 100644
--- a/Source/CMMCPResult.h
+++ b/Source/CMMCPResult.h
@@ -25,6 +25,7 @@
#import <Cocoa/Cocoa.h>
#import <MCPKit_bundled/MCPKit_bundled.h>
+#define FIELD_TYPE_BIT 16
@interface CMMCPResult : MCPResult {
diff --git a/Source/CMMCPResult.m b/Source/CMMCPResult.m
index f80ff5c3..145825a7 100644
--- a/Source/CMMCPResult.m
+++ b/Source/CMMCPResult.m
@@ -100,6 +100,10 @@ modified version for use with sequel-pro
case FIELD_TYPE_NEWDATE: // Don't know what the format for this type is...
theCurrentObj = [self stringWithCString:theData];
break;
+
+ case FIELD_TYPE_BIT:
+ theCurrentObj = [NSString stringWithFormat:@"%u", theData[0]];
+ break;
case FIELD_TYPE_TINY_BLOB:
case FIELD_TYPE_BLOB:
diff --git a/Source/CustomQuery.m b/Source/CustomQuery.m
index 04b4b9f8..e917e984 100644
--- a/Source/CustomQuery.m
+++ b/Source/CustomQuery.m
@@ -480,6 +480,10 @@ inserts the query in the textView and performs query
if ( [[theRow objectAtIndex:[theIdentifier intValue]] isKindOfClass:[NSData class]] ) {
NSString *tmp = [[NSString alloc] initWithData:[theRow objectAtIndex:[theIdentifier intValue]]
encoding:[mySQLConnection encoding]];
+ if (tmp == nil) {
+ tmp = [[NSString alloc] initWithData:[theRow objectAtIndex:[theIdentifier intValue]]
+ encoding:NSASCIIStringEncoding];
+ }
return [tmp autorelease];
}
if ( [[theRow objectAtIndex:[theIdentifier intValue]] isMemberOfClass:[NSNull class]] )
@@ -636,6 +640,10 @@ opens sheet with value when double clicking on a field
if ( [[theRow objectAtIndex:[theIdentifier intValue]] isKindOfClass:[NSData class]] ) {
theValue = [[NSString alloc] initWithData:[theRow objectAtIndex:[theIdentifier intValue]]
encoding:[mySQLConnection encoding]];
+ if (theValue == nil) {
+ theValue = [[NSString alloc] initWithData:[theRow objectAtIndex:[theIdentifier intValue]]
+ encoding:NSASCIIStringEncoding];
+ }
[theValue autorelease];
} else if ( [[theRow objectAtIndex:[theIdentifier intValue]] isMemberOfClass:[NSNull class]] ) {
theValue = [prefs objectForKey:@"nullValue"];
diff --git a/Source/TableContent.h b/Source/TableContent.h
index e0802e3b..5847b868 100644
--- a/Source/TableContent.h
+++ b/Source/TableContent.h
@@ -65,7 +65,7 @@
NSString *compareType, *sortField;
BOOL isEditingRow, isEditingNewRow, isDesc, setLimit;
NSUserDefaults *prefs;
- int numRows;
+ int numRows, currentlyEditingRow;
bool areShowingAllRows;
}
@@ -105,6 +105,7 @@
- (void)sheetDidEnd:(NSWindow *)sheet returnCode:(int)returnCode contextInfo:(NSString *)contextInfo;
- (int)getNumberOfRows;
- (int)fetchNumberOfRows;
+- (BOOL)saveRowOnDeselect;
//tableView datasource methods
- (int)numberOfRowsInTableView:(NSTableView *)aTableView;
@@ -118,7 +119,6 @@ objectValueForTableColumn:(NSTableColumn *)aTableColumn
//tableView delegate methods
- (void)tableView:(NSTableView*)tableView didClickTableColumn:(NSTableColumn *)tableColumn;
-- (BOOL)selectionShouldChangeInTableView:(NSTableView *)aTableView;
- (void)tableViewSelectionDidChange:(NSNotification *)aNotification;
- (void)tableViewSelectionIsChanging:(NSNotification *)aNotification;
- (void)tableViewColumnDidResize:(NSNotification *)aNotification;
diff --git a/Source/TableContent.m b/Source/TableContent.m
index b3044c94..1e40e99d 100644
--- a/Source/TableContent.m
+++ b/Source/TableContent.m
@@ -44,6 +44,7 @@
selectedTable = nil;
sortField = nil;
areShowingAllRows = false;
+ currentlyEditingRow = -1;
return self;
}
@@ -312,6 +313,10 @@
*/
- (IBAction)reloadTable:(id)sender
{
+
+ // Check whether a save of the current row is required.
+ if ( ![self saveRowOnDeselect] ) return;
+
// Store the current viewport location
NSRect viewRect = [tableContentView visibleRect];
@@ -398,6 +403,12 @@
NSString *queryString;
int i;
+ // Check whether a save of the current row is required.
+ if ( ![self saveRowOnDeselect] ) {
+ [argument release];
+ return;
+ }
+
// Update negative limits
if ( [limitRowsField intValue] <= 0 ) {
[limitRowsField setStringValue:@"1"];
@@ -583,6 +594,10 @@
*/
- (IBAction)showAll:(id)sender
{
+
+ // Check whether a save of the current row is required.
+ if ( ![self saveRowOnDeselect] ) return;
+
[filteredResult setArray:fullResult];
[tableContentView reloadData];
areShowingAllRows = YES;
@@ -611,8 +626,8 @@
NSMutableDictionary *column, *newRow = [NSMutableDictionary dictionary];
int i;
- if ( ![self selectionShouldChangeInTableView:nil] )
- return;
+ // Check whether a save of the current row is required.
+ if ( ![self saveRowOnDeselect] ) return;
columns = [[NSArray alloc] initWithArray:[tableDataInstance columns]];
for ( i = 0 ; i < [columns count] ; i++ ) {
@@ -626,10 +641,11 @@
[filteredResult addObject:newRow];
[columns release];
- isEditingRow = YES;
- isEditingNewRow = YES;
[tableContentView reloadData];
[tableContentView selectRow:[tableContentView numberOfRows]-1 byExtendingSelection:NO];
+ isEditingRow = YES;
+ isEditingNewRow = YES;
+ currentlyEditingRow = [tableContentView selectedRow];
if ( [multipleLineEditingButton state] == NSOffState )
[tableContentView editColumn:0 row:[tableContentView numberOfRows]-1 withEvent:nil select:YES];
}
@@ -644,8 +660,9 @@
NSDictionary *row;
int i;
- if ( ![self selectionShouldChangeInTableView:nil] )
- return;
+ // Check whether a save of the current row is required.
+ if ( ![self saveRowOnDeselect] ) return;
+
if ( [tableContentView numberOfSelectedRows] < 1 )
return;
if ( [tableContentView numberOfSelectedRows] > 1 ) {
@@ -656,8 +673,6 @@
//copy row
tempRow = [NSMutableDictionary dictionaryWithDictionary:[filteredResult objectAtIndex:[tableContentView selectedRow]]];
[filteredResult insertObject:tempRow atIndex:[tableContentView selectedRow]+1];
- isEditingRow = YES;
- isEditingNewRow = YES;
//set autoincrement fields to NULL
queryResult = [mySQLConnection queryString:[NSString stringWithFormat:@"SHOW COLUMNS FROM `%@`", selectedTable]];
if ([queryResult numOfRows]) [queryResult dataSeek:0];
@@ -670,6 +685,9 @@
//select row and go in edit mode
[tableContentView reloadData];
[tableContentView selectRow:[tableContentView selectedRow]+1 byExtendingSelection:NO];
+ isEditingRow = YES;
+ isEditingNewRow = YES;
+ currentlyEditingRow = [tableContentView selectedRow];
if ( [multipleLineEditingButton state] == NSOffState )
[tableContentView editColumn:0 row:[tableContentView selectedRow] withEvent:nil select:YES];
}
@@ -679,8 +697,9 @@
asks user if he really wants to delete the selected rows
*/
{
- if ( ![self selectionShouldChangeInTableView:nil] )
- return;
+ // Check whether a save of the current row is required.
+ if ( ![self saveRowOnDeselect] ) return;
+
if ( ![tableContentView numberOfSelectedRows] )
return;
/*
@@ -1097,7 +1116,6 @@
*/
- (BOOL)addRowToDB
{
- int rowIndex = [tableContentView selectedRow];
NSArray *theColumns, *columnNames;
NSMutableArray *fieldValues = [[NSMutableArray alloc] init];
NSMutableString *queryString;
@@ -1108,11 +1126,15 @@
NSString *currentTime = [[NSDate date] descriptionWithCalendarFormat:@"%H:%M:%S" timeZone:nil locale:nil];
int i;
- if ( !isEditingRow || rowIndex == -1) {
+ if ( !isEditingRow || currentlyEditingRow == -1) {
[fieldValues release];
return YES;
}
+
+ // If editing, compare the new row to the old row and if they're the same do nothing.
+ if ( !isEditingNewRow && [oldRow isEqualToDictionary:[filteredResult objectAtIndex:currentlyEditingRow]] ) return YES;
+
// Retrieve the field names and types for this table from the data cache. This is used when requesting all data as part
// of the fieldListForQuery method, and also to decide whether or not to preserve the current filter/sort settings.
theColumns = [tableDataInstance columns];
@@ -1120,7 +1142,7 @@
// Get the field values
for ( i = 0 ; i < [columnNames count] ; i++ ) {
- rowObject = [[filteredResult objectAtIndex:rowIndex] objectForKey:[columnNames objectAtIndex:i]];
+ rowObject = [[filteredResult objectAtIndex:currentlyEditingRow] objectForKey:[columnNames objectAtIndex:i]];
// Convert the object to a string (here we can add special treatment for date-, number- and data-fields)
if ( [[rowObject description] isEqualToString:[prefs stringForKey:@"nullValue"]]
@@ -1142,6 +1164,8 @@
} else {
if ( [[rowObject description] isEqualToString:@"CURRENT_TIMESTAMP"] ) {
[rowValue setString:@"CURRENT_TIMESTAMP"];
+ } else if ([[[theColumns objectAtIndex:i] objectForKey:@"typegrouping"] isEqualToString:@"bit"]) {
+ [rowValue setString:((![[rowObject description] length] || [[rowObject description] isEqualToString:@"0"])?@"0":@"1")];
} else {
[rowValue setString:[NSString stringWithFormat:@"'%@'", [mySQLConnection prepareString:[rowObject description]]]];
}
@@ -1178,9 +1202,10 @@
} else {
NSBeep();
}
- [filteredResult replaceObjectAtIndex:rowIndex withObject:[NSMutableDictionary dictionaryWithDictionary:oldRow]];
+ [filteredResult replaceObjectAtIndex:currentlyEditingRow withObject:[NSMutableDictionary dictionaryWithDictionary:oldRow]];
isEditingRow = NO;
isEditingNewRow = NO;
+ currentlyEditingRow = -1;
[queryConsoleInstance showErrorInConsole:[NSString stringWithFormat:NSLocalizedString(@"/* WARNING %@ No rows have been affected */\n", @"warning shown in the console when no rows have been affected after writing to the db"), currentTime]];
return YES;
@@ -1193,16 +1218,17 @@
if ( [prefs boolForKey:@"reloadAfterAdding"] ) {
[self reloadTableValues:self];
[tableContentView deselectAll:self];
+ [tableWindow endEditingFor:nil];
} else {
// Set the insertId for fields with auto_increment
for ( i = 0; i < [theColumns count] ; i++ ) {
if ([[theColumns objectAtIndex:i] objectForKey:@"autoincrement"]) {
- [[filteredResult objectAtIndex:rowIndex] setObject:[NSNumber numberWithLong:[mySQLConnection insertId]]
+ [[filteredResult objectAtIndex:currentlyEditingRow] setObject:[NSNumber numberWithLong:[mySQLConnection insertId]]
forKey:[columnNames objectAtIndex:i]];
}
}
- [fullResult addObject:[filteredResult objectAtIndex:rowIndex]];
+ [fullResult addObject:[filteredResult objectAtIndex:currentlyEditingRow]];
}
isEditingNewRow = NO;
@@ -1211,6 +1237,7 @@
if ( [prefs boolForKey:@"reloadAfterEditing"] ) {
[self reloadTableValues:self];
[tableContentView deselectAll:self];
+ [tableWindow endEditingFor:nil];
// TODO: this probably needs looking at... it's reloading it all itself?
} else {
@@ -1232,6 +1259,7 @@
[fullResult setArray:[self fetchResultAsArray:queryResult]];
}
}
+ currentlyEditingRow = -1;
return YES;
// Report errors which have occurred
@@ -1242,6 +1270,27 @@
}
}
+
+/*
+ * A method to be called whenever the table selection changes; checks whether the current
+ * row is being edited, and if so attempts to save it. Returns YES if no save was necessary
+ * or the save was successful, and NO if a save was necessary and failed - in which case further
+ * editing is required. In that case this method will reselect the row in question for reediting.
+ */
+- (BOOL)saveRowOnDeselect
+{
+
+ // If no rows are currently being edited, return success at once.
+ if (!isEditingRow) return YES;
+
+ // Attempt to save the row, and return YES if the save succeeded.
+ if ([self addRowToDB]) return YES;
+
+ // Saving failed - reselect the old row and return failure.
+ [tableContentView selectRow:currentlyEditingRow byExtendingSelection:NO];
+ return NO;
+}
+
/*
* Returns the WHERE argument to identify a row.
* If "row" is -2, it uses the oldRow.
@@ -1311,6 +1360,8 @@
if ( [tempValue isKindOfClass:[NSData class]] ) {
NSString *tmpString = [[NSString alloc] initWithData:tempValue encoding:[mySQLConnection encoding]];
+ if (tmpString == nil)
+ tmpString = [[NSString alloc] initWithData:tempValue encoding:NSASCIIStringEncoding];
[value setString:[NSString stringWithString:tmpString]];
[tmpString release];
} else {
@@ -1339,7 +1390,7 @@
[value setString:[NSString stringWithFormat:@"'%@'", value]];
columnType = [[tableDataInstance columnWithName:[keys objectAtIndex:i]] objectForKey:@"typegrouping"];
- if ( [columnType isEqualToString:@"integer"] || [columnType isEqualToString:@"float"] ) {
+ if ( [columnType isEqualToString:@"integer"] || [columnType isEqualToString:@"float"] || [columnType isEqualToString:@"bit"] ) {
[argument appendString:[NSString stringWithFormat:@"`%@` = %@", [keys objectAtIndex:i], value]];
} else {
[argument appendString:[NSString stringWithFormat:@"`%@` LIKE %@", [keys objectAtIndex:i], value]];
@@ -1433,6 +1484,7 @@
isEditingRow = NO;
isEditingNewRow = NO;
}
+ currentlyEditingRow = -1;
}
[tableContentView reloadData];
} else if ( [contextInfo isEqualToString:@"removeallrows"] ) {
@@ -1556,12 +1608,14 @@ objectValueForTableColumn:(NSTableColumn *)aTableColumn
theRow = [filteredResult objectAtIndex:rowIndex];
theValue = [theRow objectForKey:[aTableColumn identifier]];
- // Convert data objects to their string representation in the current encoding.
+ // Convert data objects to their string representation in the current encoding, falling back to ascii
if ( [theValue isKindOfClass:[NSData class]] ) {
NSString *dataRepresentation = [[NSString alloc] initWithData:theValue encoding:[mySQLConnection encoding]];
+ if (dataRepresentation == nil)
+ dataRepresentation = [[NSString alloc] initWithData:theValue encoding:NSASCIIStringEncoding];
if (dataRepresentation == nil) theValue = @"- cannot be displayed -";
else theValue = [NSString stringWithString:dataRepresentation];
- [dataRepresentation release];
+ if (dataRepresentation) [dataRepresentation release];
}
return theValue;
@@ -1575,6 +1629,7 @@ objectValueForTableColumn:(NSTableColumn *)aTableColumn
if ( !isEditingRow ) {
[oldRow setDictionary:[filteredResult objectAtIndex:rowIndex]];
isEditingRow = YES;
+ currentlyEditingRow = rowIndex;
}
if ( anObject ) {
[[filteredResult objectAtIndex:rowIndex] setObject:anObject forKey:[aTableColumn identifier]];
@@ -1597,9 +1652,10 @@ objectValueForTableColumn:(NSTableColumn *)aTableColumn
if ( [selectedTable isEqualToString:@""] || !selectedTable )
return;
- if ( ![self selectionShouldChangeInTableView:nil] )
- return;
+ // Check whether a save of the current row is required.
+ if ( ![self saveRowOnDeselect] ) return;
+
//query started
[[NSNotificationCenter defaultCenter] postNotificationName:@"SMySQLQueryWillBePerformed" object:self];
@@ -1660,32 +1716,16 @@ objectValueForTableColumn:(NSTableColumn *)aTableColumn
}
}
-- (BOOL)selectionShouldChangeInTableView:(NSTableView *)aTableView
-{
- /*
- int row = [tableContentView editedRow];
- int column = [tableContentView editedColumn];
- NSTableColumn *tableColumn;
- NSCell *cell;
-
- if ( row != -1 ) {
- tableColumn = [[tableContentView tableColumns] objectAtIndex:column];
- cell = [tableColumn dataCellForRow:row];
- [cell endEditing:[tableContentView currentEditor]];
- }
- */
- //end editing (otherwise problems when user hits reload button)
- [tableWindow endEditingFor:nil];
-
- return [self addRowToDB];
-}
-
- (void)tableViewSelectionDidChange:(NSNotification *)aNotification
{
// Check our notification object is our table content view
if ([aNotification object] != tableContentView)
return;
+
+ // If we are editing a row, attempt to save that row - if saving failed, reselect the edit row.
+ if ( isEditingRow && [tableContentView selectedRow] != currentlyEditingRow && ![self saveRowOnDeselect] ) return;
+ // Update the row selection count
if ( [tableContentView numberOfSelectedRows] > 0 ) {
[countText setStringValue:[NSString stringWithFormat:NSLocalizedString(@"%d of %d rows selected", @"Text showing how many rows are selected"), [tableContentView numberOfSelectedRows], [tableContentView numberOfRows]]];
} else {
@@ -1750,7 +1790,7 @@ objectValueForTableColumn:(NSTableColumn *)aTableColumn
- (BOOL)tableView:(NSTableView *)aTableView shouldEditTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex
{
int code;
- NSString *columnTypeGrouping, *query;
+ NSString *columnTypeGrouping, *query, *stringValue = nil;
NSEnumerator *enumerator;
NSDictionary *tempRow;
NSMutableDictionary *modifiedRow = [NSMutableDictionary dictionary];
@@ -1800,15 +1840,20 @@ objectValueForTableColumn:(NSTableColumn *)aTableColumn
if ( [theValue isKindOfClass:[NSData class]] ) {
image = [[NSImage alloc] initWithData:theValue];
[hexTextView setString:[self dataToHex:theValue]];
- theValue = [[NSString alloc] initWithData:theValue encoding:[mySQLConnection encoding]];
+ stringValue = [[NSString alloc] initWithData:theValue encoding:[mySQLConnection encoding]];
+ if (stringValue == nil)
+ stringValue = [[NSString alloc] initWithData:theValue encoding:NSASCIIStringEncoding];
} else {
[hexTextView setString:@""];
- theValue = [theValue description];
+ stringValue = [[NSString alloc] initWithString:[theValue description]];
}
[editImage setImage:image];
- [editTextView setString:theValue];
- [editTextView setSelectedRange:NSMakeRange(0,[[editTextView string] length])];
+ if (stringValue) {
+ [editTextView setString:stringValue];
+ [editTextView setSelectedRange:NSMakeRange(0,[[editTextView string] length])];
+ [stringValue release];
+ }
[NSApp beginSheet:editSheet modalForWindow:tableWindow modalDelegate:self didEndSelector:nil contextInfo:nil];
code = [NSApp runModalForWindow:editSheet];
@@ -1820,6 +1865,7 @@ objectValueForTableColumn:(NSTableColumn *)aTableColumn
if ( !isEditingRow ) {
[oldRow setDictionary:[filteredResult objectAtIndex:rowIndex]];
isEditingRow = YES;
+ currentlyEditingRow = rowIndex;
}
[[filteredResult objectAtIndex:rowIndex] setObject:[editData copy] forKey:[aTableColumn identifier]];
@@ -1924,6 +1970,7 @@ objectValueForTableColumn:(NSTableColumn *)aTableColumn
[filteredResult removeObjectAtIndex:row];
[tableContentView reloadData];
}
+ currentlyEditingRow = -1;
return TRUE;
}
else
diff --git a/Source/TableDocument.m b/Source/TableDocument.m
index f8c6bc73..ea02dd20 100644
--- a/Source/TableDocument.m
+++ b/Source/TableDocument.m
@@ -1159,6 +1159,13 @@ NSString *TableDocumentFavoritesControllerFavoritesDidChange = @"TableDocumentFa
- (IBAction)viewStructure:(id)sender
{
+ // Cancel the selection if currently editing a content row and unable to save
+ if ([tableTabView indexOfTabViewItem:[tableTabView selectedTabViewItem]] == 1
+ && ![tableContentInstance saveRowOnDeselect]) {
+ [mainToolbar setSelectedItemIdentifier:@"SwitchToTableContentToolbarItemIdentifier"];
+ return;
+ }
+
[tableTabView selectTabViewItemAtIndex:0];
[mainToolbar setSelectedItemIdentifier:@"SwitchToTableStructureToolbarItemIdentifier"];
}
@@ -1171,12 +1178,26 @@ NSString *TableDocumentFavoritesControllerFavoritesDidChange = @"TableDocumentFa
- (IBAction)viewQuery:(id)sender
{
+ // Cancel the selection if currently editing a content row and unable to save
+ if ([tableTabView indexOfTabViewItem:[tableTabView selectedTabViewItem]] == 1
+ && ![tableContentInstance saveRowOnDeselect]) {
+ [mainToolbar setSelectedItemIdentifier:@"SwitchToTableContentToolbarItemIdentifier"];
+ return;
+ }
+
[tableTabView selectTabViewItemAtIndex:2];
[mainToolbar setSelectedItemIdentifier:@"SwitchToRunQueryToolbarItemIdentifier"];
}
- (IBAction)viewStatus:(id)sender
{
+ // Cancel the selection if currently editing a content row and unable to save
+ if ([tableTabView indexOfTabViewItem:[tableTabView selectedTabViewItem]] == 1
+ && ![tableContentInstance saveRowOnDeselect]) {
+ [mainToolbar setSelectedItemIdentifier:@"SwitchToTableContentToolbarItemIdentifier"];
+ return;
+ }
+
[tableTabView selectTabViewItemAtIndex:3];
[mainToolbar setSelectedItemIdentifier:@"SwitchToTableStatusToolbarItemIdentifier"];
}
@@ -1432,7 +1453,7 @@ NSString *TableDocumentFavoritesControllerFavoritesDidChange = @"TableDocumentFa
- (void)windowWillClose:(NSNotification *)aNotification
{
if ([mySQLConnection isConnected]) [self closeConnection];
-
+ if ([[queryConsoleInstance window] isVisible]) [self toggleConsole:self];
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
@@ -1571,6 +1592,9 @@ objectValueForTableColumn:(NSTableColumn *)aTableColumn
if ( [theValue isKindOfClass:[NSData class]] ) {
theValue = [[NSString alloc] initWithData:theValue encoding:[mySQLConnection encoding]];
+ if (theValue == nil) {
+ [[NSString alloc] initWithData:theValue encoding:NSASCIIStringEncoding];
+ }
}
return theValue;
diff --git a/Source/TableDump.m b/Source/TableDump.m
index 0b134bf3..5c813407 100644
--- a/Source/TableDump.m
+++ b/Source/TableDump.m
@@ -1098,6 +1098,8 @@
// Retrieve the contents of this cell
if ([[csvRow objectAtIndex:j] isKindOfClass:[NSData class]]) {
dataConversionString = [[NSString alloc] initWithData:[csvRow objectAtIndex:j] encoding:tableEncoding];
+ if (dataConversionString == nil)
+ dataConversionString = [[NSString alloc] initWithData:[csvRow objectAtIndex:j] encoding:NSASCIIStringEncoding];
[csvCell setString:[NSString stringWithString:dataConversionString]];
[dataConversionString release];
} else {
@@ -1438,6 +1440,8 @@
// Retrieve the contents of this tag
if ([[xmlRow objectAtIndex:j] isKindOfClass:[NSData class]]) {
dataConversionString = [[NSString alloc] initWithData:[xmlRow objectAtIndex:j] encoding:tableEncoding];
+ if (dataConversionString == nil)
+ dataConversionString = [[NSString alloc] initWithData:[xmlRow objectAtIndex:j] encoding:NSASCIIStringEncoding];
[xmlItem setString:[NSString stringWithString:dataConversionString]];
[dataConversionString release];
} else {
diff --git a/Source/TablesList.m b/Source/TablesList.m
index f5f8a16f..ad3c0217 100644
--- a/Source/TablesList.m
+++ b/Source/TablesList.m
@@ -98,7 +98,7 @@ adds a new table to the tables-array (no changes in mysql-db)
- (IBAction)addTable:(id)sender
{
if ( ![tableSourceInstance selectionShouldChangeInTableView:nil] ||
- ![tableContentInstance selectionShouldChangeInTableView:nil] ||
+ ![tableContentInstance saveRowOnDeselect] ||
![tableDocumentInstance database] )
return;
[tableWindow endEditingFor:nil];
@@ -151,7 +151,7 @@ copies a table, if desired with content
if ( [tablesListView numberOfSelectedRows] != 1 )
return;
- if ( ![tableSourceInstance selectionShouldChangeInTableView:nil] || ![tableContentInstance selectionShouldChangeInTableView:nil] )
+ if ( ![tableSourceInstance selectionShouldChangeInTableView:nil] || ![tableContentInstance saveRowOnDeselect] )
return;
[tableWindow endEditingFor:nil];
@@ -588,7 +588,7 @@ traps enter and esc and edit/cancel without entering next row
//we have to be sure that TableSource and TableContent have finished editing
// if ( ![tableSourceInstance addRowToDB] || ![tableContentInstance addRowToDB] ) {
if ( ![tableSourceInstance selectionShouldChangeInTableView:nil] ||
- ![tableContentInstance selectionShouldChangeInTableView:nil] ) {
+ ![tableContentInstance saveRowOnDeselect] ) {
return NO;
} else {
return YES;