From b6e085eb89bcea1079b7892c6a67176771a25adb Mon Sep 17 00:00:00 2001 From: Max Date: Fri, 5 Jan 2018 01:29:29 +0100 Subject: Fix an issue where the contents of a duplicated query favorite would be overwritten if the selection was changed bevore saving (#2938) --- Source/SPQueryFavoriteManager.m | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'Source') 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) { -- cgit v1.2.3