From fa8bc031af44a2ae8e9d71bddaa2fb7770774b42 Mon Sep 17 00:00:00 2001 From: stuconnolly Date: Mon, 3 Aug 2009 15:25:15 +0000 Subject: Don't release the server variables array as it's simply a weak reference when filtering is not taking place, fixes a crash. Also, if the panel is opened and the search field contains a value that was previously filter using, perform the filtering using this value before the sheet is displayed. --- Source/TableDocument.m | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'Source') diff --git a/Source/TableDocument.m b/Source/TableDocument.m index 07a8538f..77bc78d7 100644 --- a/Source/TableDocument.m +++ b/Source/TableDocument.m @@ -1311,11 +1311,6 @@ int i; NSMutableArray *tempResult = [NSMutableArray array]; - if (variables) { - [variables release]; - variables = nil; - } - if (variablesFiltered) { [variablesFiltered release]; variablesFiltered = nil; @@ -1332,11 +1327,16 @@ variablesFiltered = [[NSArray arrayWithArray:tempResult] retain]; - // Weak pointer + // Weak reference variables = variablesFiltered; [variablesTableView reloadData]; + // If the search field already has value from when the panel was previously open, apply the filter. + if ([[variablesSearchField stringValue] length] > 0) { + [self _updateServerVariablesFilterForFilterString:[variablesSearchField stringValue]]; + } + // Show variables sheet [NSApp beginSheet:variablesSheet modalForWindow:tableWindow modalDelegate:self @@ -2155,7 +2155,7 @@ } if (object == variablesSearchField) { - [self _updateServerVariablesFilterForFilterString:[[object stringValue] lowercaseString]]; + [self _updateServerVariablesFilterForFilterString:[object stringValue]]; } } @@ -2257,6 +2257,8 @@ { [saveVariablesButton setEnabled:NO]; + filterString = [filterString lowercaseString]; + filterString = [filterString stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; variables = [[NSMutableArray alloc] init]; -- cgit v1.2.3