From bd96d373385c8d2aff108269c1e89063cd48e416 Mon Sep 17 00:00:00 2001 From: dmoagx Date: Wed, 24 Aug 2011 21:37:52 +0000 Subject: * Fixes sorting of integer values in server process list (issue #1159) --- Source/SPProcessListController.m | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/Source/SPProcessListController.m b/Source/SPProcessListController.m index 3745d4e0..5ca669df 100644 --- a/Source/SPProcessListController.m +++ b/Source/SPProcessListController.m @@ -697,8 +697,29 @@ static const NSString *SPTableViewIDColumnIdentifier = @"Id"; for (i = 0; i < [processList numOfRows]; i++) { - [processes addObject:[processList fetchRowAsDictionary]]; + //MCPKit currently returns numbers as NSString, which will break sorting of numbers in this case. + NSMutableDictionary *rowsFixed = [[processList fetchRowAsDictionary] mutableCopy]; + + id idColumn = [rowsFixed objectForKey:@"Id"]; + //Id is a signed int(11) - this is a signed 32 bit int value + if(idColumn != nil && [idColumn isKindOfClass:[NSString class]]) { + int numRaw = [(NSString *)idColumn intValue]; + NSNumber *num = [NSNumber numberWithInt:numRaw]; + [rowsFixed setObject:num forKey:@"Id"]; + } + + id timeColumn = [rowsFixed objectForKey:@"Time"]; + //Time is a signed int(7) - this is the same 32 bit int value + if(timeColumn != nil && [timeColumn isKindOfClass:[NSString class]]) { + int numRaw = [(NSString *)timeColumn intValue]; + NSNumber *num = [NSNumber numberWithInt:numRaw]; + [rowsFixed setObject:num forKey:@"Time"]; + } + + [processes addObject:[[rowsFixed copy] autorelease]]; + [rowsFixed release]; } + } // Update the UI on the main thread -- cgit v1.2.3