aboutsummaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorMax <post@wickenrode.com>2018-01-05 01:29:29 +0100
committerMax <post@wickenrode.com>2018-01-05 01:29:29 +0100
commitb6e085eb89bcea1079b7892c6a67176771a25adb (patch)
treecc900d99029603fc828ef558872a058777247342 /Source
parent2f0099e1bf3caf42cfe76aa4074efdfc7f351cef (diff)
downloadsequelpro-b6e085eb89bcea1079b7892c6a67176771a25adb.tar.gz
sequelpro-b6e085eb89bcea1079b7892c6a67176771a25adb.tar.bz2
sequelpro-b6e085eb89bcea1079b7892c6a67176771a25adb.zip
Fix an issue where the contents of a duplicated query favorite would be overwritten if the selection was changed bevore saving (#2938)
Diffstat (limited to 'Source')
-rw-r--r--Source/SPQueryFavoriteManager.m16
1 files changed, 12 insertions, 4 deletions
diff --git a/Source/SPQueryFavoriteManager.m b/Source/SPQueryFavoriteManager.m
index 2f88bbcf..63726243 100644
--- a/Source/SPQueryFavoriteManager.m
+++ b/Source/SPQueryFavoriteManager.m
@@ -201,11 +201,19 @@
[[self window] makeFirstResponder:favoriteNameTextField];
// Duplicate a selected favorite if sender == self
- if (sender == self)
- favorite = [NSMutableDictionary dictionaryWithObjects:[NSArray arrayWithObjects:[[favoriteNameTextField stringValue] stringByAppendingFormat:@" Copy"], [favoriteQueryTextView string], nil] forKeys:[NSArray arrayWithObjects:@"name", @"query", nil]];
+ if (sender == self) {
+ favorite = [NSMutableDictionary dictionaryWithDictionary:@{
+ @"name": [NSString stringWithFormat:NSLocalizedString(@"%@ Copy", @"query favorite manager : duplicate favorite : new favorite name"),[favoriteNameTextField stringValue]],
+ @"query": [NSString stringWithString:[favoriteQueryTextView string]] // #2938 - without copying the string we would store the live NS*MutableString object that backs the text view and changes its contents when selection changes!
+ }];
+ }
// Add a new favorite
- else
- favorite = [NSMutableDictionary dictionaryWithObjects:@[@"New Favorite", @""] forKeys:@[@"name", @"query"]];
+ else {
+ favorite = [NSMutableDictionary dictionaryWithDictionary:@{
+ @"name": NSLocalizedString(@"New Favorite",@"query favorite manager : new favorite : name"),
+ @"query": @""
+ }];
+ }
// If a favourite is currently selected, add the new favourite next to it
if ([favoritesTableView numberOfSelectedRows] > 0) {