From e8d8d6cc38cc92b7201806ed42db50a4c4b324ea Mon Sep 17 00:00:00 2001 From: rowanbeentje Date: Wed, 11 Mar 2009 02:10:25 +0000 Subject: - Increment trunk version number to 0.9.4 - Improves on r370 and r375 by preventing actions triggered by the save from triggering saves themselves - Improves further on r370 and r375 by committing any current edits before saving - Additional comments --- Interfaces/English.lproj/InfoPlist.strings | 2 +- Resources/Info.plist | 4 ++-- Source/TableContent.h | 2 +- Source/TableContent.m | 17 ++++++++++++++--- Source/TableSource.h | 2 +- Source/TableSource.m | 14 +++++++++++--- 6 files changed, 30 insertions(+), 11 deletions(-) diff --git a/Interfaces/English.lproj/InfoPlist.strings b/Interfaces/English.lproj/InfoPlist.strings index e110fa52..a213db55 100644 --- a/Interfaces/English.lproj/InfoPlist.strings +++ b/Interfaces/English.lproj/InfoPlist.strings @@ -1,4 +1,4 @@ /* Localized versions of Info.plist keys */ -CFBundleGetInfoString = "Sequel Pro version 0.9.3, Copyright 2002-2009 Sequel Pro and CocoaMySQL team."; +CFBundleGetInfoString = "Sequel Pro version 0.9.4, Copyright 2002-2009 Sequel Pro and CocoaMySQL team."; NSHumanReadableCopyright = "Copyright 2002-2009 Sequel Pro and CocoaMySQL team."; \ No newline at end of file diff --git a/Resources/Info.plist b/Resources/Info.plist index ab10cc48..ce1a9673 100644 --- a/Resources/Info.plist +++ b/Resources/Info.plist @@ -42,13 +42,13 @@ CFBundlePackageType APPL CFBundleShortVersionString - 0.9.3 + 0.9.4 CFBundleVersion NSAppleScriptEnabled YES NSHumanReadableCopyright - 0.9.3 (238) + 0.9.4 (387) NSMainNibFile MainMenu NSPrincipalClass diff --git a/Source/TableContent.h b/Source/TableContent.h index e999e5e4..f18659a0 100644 --- a/Source/TableContent.h +++ b/Source/TableContent.h @@ -64,7 +64,7 @@ NSMutableArray *fullResult, *filteredResult, *keys; NSMutableDictionary *oldRow; NSString *compareType, *sortField; - BOOL isEditingRow, isEditingNewRow, isDesc, setLimit; + BOOL isEditingRow, isEditingNewRow, isSavingRow, isDesc, setLimit; NSUserDefaults *prefs; int numRows, currentlyEditingRow; bool areShowingAllRows; diff --git a/Source/TableContent.m b/Source/TableContent.m index 156ce5c8..3443a73f 100644 --- a/Source/TableContent.m +++ b/Source/TableContent.m @@ -1323,14 +1323,22 @@ - (BOOL)saveRowOnDeselect { - // If no rows are currently being edited, return success at once. - if (!isEditingRow) return YES; + // If no rows are currently being edited, or a save is in progress, return success at once. + if (!isEditingRow || isSavingRow) return YES; + isSavingRow = YES; + + // Save any edits which have been made but not saved to the table yet. + [tableWindow endEditingFor:nil]; // Attempt to save the row, and return YES if the save succeeded. - if ([self addRowToDB]) return YES; + if ([self addRowToDB]) { + isSavingRow = NO; + return YES; + } // Saving failed - reselect the old row and return failure. [tableContentView selectRow:currentlyEditingRow byExtendingSelection:NO]; + isSavingRow = NO; return NO; } @@ -1669,6 +1677,9 @@ objectValueForTableColumn:(NSTableColumn *)aTableColumn forTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex { + + // Catch editing events in the row and if the row isn't currently being edited, + // start an edit. This allows edits including enum changes to save correctly. if ( !isEditingRow ) { [oldRow setDictionary:[filteredResult objectAtIndex:rowIndex]]; isEditingRow = YES; diff --git a/Source/TableSource.h b/Source/TableSource.h index c66ec71f..e97602f5 100644 --- a/Source/TableSource.h +++ b/Source/TableSource.h @@ -59,7 +59,7 @@ NSMutableArray *tableFields, *indexes; NSMutableDictionary *oldRow, *enumFields; NSDictionary *defaultValues; - BOOL isEditingRow, isEditingNewRow, alertSheetOpened; + BOOL isEditingRow, isEditingNewRow, isSavingRow, alertSheetOpened; int currentlyEditingRow; NSUserDefaults *prefs; } diff --git a/Source/TableSource.m b/Source/TableSource.m index c66f5972..5d1c8e43 100644 --- a/Source/TableSource.m +++ b/Source/TableSource.m @@ -565,14 +565,22 @@ fetches the result as an array with a dictionary for each row in it */ - (BOOL)saveRowOnDeselect { - // If no rows are currently being edited, return success at once. - if (!isEditingRow) return YES; + // If no rows are currently being edited, or a save is already in progress, return success at once. + if (!isEditingRow || isSavingRow) return YES; + isSavingRow = YES; + + // Save any edits which have been made but not saved to the table yet. + [tableWindow endEditingFor:nil]; // Attempt to save the row, and return YES if the save succeeded. - if ([self addRowToDB]) return YES; + if ([self addRowToDB]) { + isSavingRow = NO; + return YES; + } // Saving failed - reselect the old row and return failure. [tableSourceView selectRow:currentlyEditingRow byExtendingSelection:NO]; + isSavingRow = NO; return NO; } -- cgit v1.2.3