aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Source/SPHistoryController.h4
-rw-r--r--Source/SPHistoryController.m14
-rw-r--r--Source/TableDocument.m13
-rw-r--r--Source/TablesList.m3
4 files changed, 24 insertions, 10 deletions
diff --git a/Source/SPHistoryController.h b/Source/SPHistoryController.h
index 3e3c5452..4924d036 100644
--- a/Source/SPHistoryController.h
+++ b/Source/SPHistoryController.h
@@ -42,9 +42,11 @@ enum sphistory_view_types
TableContent *tableContentInstance;
NSMutableArray *history;
unsigned int historyPosition;
- BOOL restoringHistoryState;
+ BOOL modifyingHistoryState;
}
+@property (readwrite, assign) BOOL modifyingHistoryState;
+
// Interface interaction
- (void) updateToolbarItem;
- (IBAction) historyControlClicked:(NSSegmentedControl *)theControl;
diff --git a/Source/SPHistoryController.m b/Source/SPHistoryController.m
index acd25ea0..69ec9e57 100644
--- a/Source/SPHistoryController.m
+++ b/Source/SPHistoryController.m
@@ -30,6 +30,8 @@
@implementation SPHistoryController
+@synthesize modifyingHistoryState;
+
#pragma mark Setup and teardown
/**
@@ -40,7 +42,7 @@
if (self = [super init]) {
history = [[NSMutableArray alloc] init];
historyPosition = NSNotFound;
- restoringHistoryState = NO;
+ modifyingHistoryState = NO;
}
return self;
}
@@ -134,7 +136,7 @@
{
// Don't modify anything if we're in the process of restoring an old history state
- if (restoringHistoryState) return;
+ if (modifyingHistoryState) return;
// Work out the current document details
NSString *theDatabase = [theDocument database];
@@ -217,7 +219,7 @@
return;
}
- restoringHistoryState = YES;
+ modifyingHistoryState = YES;
// Update the position and extract the history entry
historyPosition = position;
@@ -236,7 +238,7 @@
&& [[historyEntry objectForKey:@"view"] intValue] == [self currentlySelectedView] == SP_VIEW_CONTENT)
{
[tableContentInstance loadTable:[historyEntry objectForKey:@"table"]];
- restoringHistoryState = NO;
+ modifyingHistoryState = NO;
[self updateToolbarItem];
return;
}
@@ -293,7 +295,7 @@
}
}
- restoringHistoryState = NO;
+ modifyingHistoryState = NO;
[self updateToolbarItem];
}
@@ -304,7 +306,7 @@
- (void) abortEntryLoad
{
NSBeep();
- restoringHistoryState = NO;
+ modifyingHistoryState = NO;
}
@end
diff --git a/Source/TableDocument.m b/Source/TableDocument.m
index e6346ece..68b79a1a 100644
--- a/Source/TableDocument.m
+++ b/Source/TableDocument.m
@@ -409,8 +409,12 @@
return;
}
- // Save existing scroll position and details
- [spHistoryControllerInstance updateHistoryEntries];
+ // Save existing scroll position and details, and ensure no duplicate entries are created as table list changes
+ BOOL historyStateChanging = [spHistoryControllerInstance modifyingHistoryState];
+ if (!historyStateChanging) {
+ [spHistoryControllerInstance updateHistoryEntries];
+ [spHistoryControllerInstance setModifyingHistoryState:YES];
+ }
// show error on connection failed
if ( ![mySQLConnection selectDB:[chooseDatabaseButton titleOfSelectedItem]] ) {
@@ -429,7 +433,10 @@
[tableWindow setTitle:[NSString stringWithFormat:@"(MySQL %@) %@/%@", mySQLVersion, [self name], [self database]]];
// Add a history entry
- [spHistoryControllerInstance updateHistoryEntries];
+ if (!historyStateChanging) {
+ [spHistoryControllerInstance setModifyingHistoryState:NO];
+ [spHistoryControllerInstance updateHistoryEntries];
+ }
// Set focus to table list filter field if visible
// otherwise set focus to Table List view
diff --git a/Source/TablesList.m b/Source/TablesList.m
index 19bafc78..4f852f9b 100644
--- a/Source/TablesList.m
+++ b/Source/TablesList.m
@@ -207,6 +207,7 @@
selectedTableName = [[NSString alloc] initWithString:[tables objectAtIndex:itemToReselect]];
selectedTableType = [[tableTypes objectAtIndex:itemToReselect] intValue];
} else {
+ if (selectedTableName) [selectedTableName release];
selectedTableName = nil;
selectedTableType = SP_TABLETYPE_NONE;
}
@@ -222,6 +223,8 @@
else if (tableListContainsViews) [[listFilterField cell] setPlaceholderString:NSLocalizedString(@"Filter tables and views", @"Filter placeholder when tables and views are present")];
else [[listFilterField cell] setPlaceholderString:NSLocalizedString(@"Filter the list of tables", @"Filter placeholder when only tables are present")];
}
+
+ if (previousSelectedTable) [previousSelectedTable release];
}
/**