Changeset 28 for Trunk/AILogSizeSort.m

Show
Ignore:
Timestamp:
06/20/09 12:52:08 (13 years ago)
Author:
jon
Message:

Modified the sort function to not crash when sorting groups.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • Trunk/AILogSizeSort.m

    r26 r28  
    274274NSComparisonResult logSizeSort(id objectA, id objectB, BOOL groups, id<AIContainingObject> container) 
    275275{ 
    276         if(groups) 
     276        // Borrowed from AISortController.m 
     277        BOOL objectAIsGroup = [objectA isKindOfClass:[AIListGroup class]]; 
     278        BOOL objectBIsGroup = [objectB isKindOfClass:[AIListGroup class]]; 
     279         
     280        if(groups || (objectAIsGroup && objectBIsGroup)) 
    277281        { 
    278282                // Keep groups in manual order (borrowed from ESStatusSort) 
     
    285289                        return NSOrderedAscending; 
    286290                } 
     291        } 
     292         
     293        // Catch cases where only one of the objects is a group 
     294        if(objectAIsGroup && !objectBIsGroup) 
     295        { 
     296                return NSOrderedAscending; 
     297        } 
     298        else if(!objectAIsGroup && objectBIsGroup) 
     299        { 
     300                return NSOrderedDescending; 
    287301        } 
    288302