Changeset 3346

Show
Ignore:
Timestamp:
08/27/06 21:41:37 (2 years ago)
Author:
timothy
Message:

Code clean up and fixes to prevent exceptions about inserting nil objects. Fixes #835, #780, #567

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/Additions/NSURLAdditions.m

    r3072 r3346  
    77        FSRef ref; 
    88        if( FSPathMakeRef( (UInt8 *)fileSystemPath, &ref, NULL ) ) { 
    9                 NSLog( @"Couldn't make FSRef from: %@", path ); 
     9                if( NSDebugEnabled ) NSLog( @"Couldn't make FSRef from: %@", path ); 
    1010                return nil; 
    1111        } 
    1212 
    1313        short fileRefNum = 0; 
    14         if( ( fileRefNum = FSOpenResFile(&ref, fsRdPerm ) ) == -1 ) { 
    15                 NSLog(@"Couldn't open inetloc file at: %@", path); 
     14        if( ( fileRefNum = FSOpenResFile( &ref, fsRdPerm ) ) == -1 ) { 
     15                if( NSDebugEnabled ) NSLog(@"Couldn't open inetloc file at: %@", path); 
    1616                return nil; 
    1717        } 
    1818 
    1919        if( ! Count1Resources('url ') ) { 
    20                 NSLog(@"Inetloc file '%@' contains no 'url ' resources", path); 
     20                if( NSDebugEnabled ) NSLog(@"Inetloc file '%@' contains no 'url ' resources", path); 
    2121                CloseResFile( fileRefNum ); 
    2222                return nil; 
     
    4444        FSRef ref, parentRef; 
    4545        if( FSPathMakeRef( (unsigned char *) fileSystemPath, &parentRef, FALSE ) ) { 
    46                 NSLog( @"Couldn't make FSRef from: %@", parentPath ); 
     46                if( NSDebugEnabled ) NSLog( @"Couldn't make FSRef from: %@", parentPath ); 
    4747                return; 
    4848        } 
     
    5555 
    5656        if( ( fileRefNum = FSOpenResFile( &ref, fsWrPerm ) ) == -1 ) { 
    57                 NSLog( @"Couldn't open inetloc at: %@", path ); 
     57                if( NSDebugEnabled ) NSLog( @"Couldn't open inetloc at: %@", path ); 
    5858                [[NSFileManager defaultManager] removeFileAtPath:path handler:nil]; 
    5959                return; 
  • trunk/Colloquy.pch

    r3344 r3346  
    66#import <AGRegex/AGRegex.h> 
    77#import <ChatCore/ChatCore.h> 
     8#import <Foundation/NSDebug.h> 
    89 
    910#endif 
  • trunk/Controllers/JVChatController.m

    r3259 r3346  
    195195                windowController = [[[JVTabbedChatWindowController alloc] init] autorelease]; 
    196196        else windowController = [[[JVChatWindowController alloc] init] autorelease]; 
    197         [_chatWindows addObject:windowController]; 
     197        if( windowController )  
     198                [_chatWindows addObject:windowController]; 
    198199        return windowController; 
    199200} 
     
    355356        JVSmartTranscriptPanel *smartTranscript = nil; 
    356357 
    357         while( ( smartTranscript = [enumerator nextObject] ) ) 
    358                 [smartTranscripts addObject:[NSKeyedArchiver archivedDataWithRootObject:smartTranscript]]; 
     358        while( ( smartTranscript = [enumerator nextObject] ) ) { 
     359                NSData *archived = [NSKeyedArchiver archivedDataWithRootObject:smartTranscript] 
     360                if( archived ) [smartTranscripts addObject:archived]; 
     361        } 
    359362 
    360363        [[self class] refreshSmartTranscriptMenu]; 
  • trunk/Controllers/JVChatWindowController.m

    r3325 r3346  
    451451                        [ret addObject:controller]; 
    452452 
    453         return [NSArray arrayWithArray:ret]
     453        return ret
    454454} 
    455455 
     
    466466                        [ret addObject:controller]; 
    467467 
    468         return [NSArray arrayWithArray:ret]
     468        return ret
    469469} 
    470470 
  • trunk/Controllers/MVApplicationController.m

    r3310 r3346  
    2424 
    2525#import <Sparkle/SUUpdater.h> 
    26 #import <Foundation/NSDebug.h> 
    2726 
    2827@interface WebCoreCache 
  • trunk/Controllers/MVConnectionsController.m

    r3307 r3346  
    7070                if( [[item pathExtension] isEqualToString:@"inetloc"] ) { 
    7171                        url = [NSURL URLWithInternetLocationFile:[[NSString stringWithFormat:@"~/Library/Application Support/Colloquy/Favorites/%@", item] stringByExpandingTildeInPath]]; 
    72                         [rooms addObject:url]; 
    73                         [roomNames addObject:[item stringByDeletingPathExtension]]; 
     72                        if( url ) { 
     73                                [rooms addObject:url]; 
     74                                [roomNames addObject:[item stringByDeletingPathExtension]]; 
     75                        } 
    7476                } 
    7577        } 
     
    413415                MVChatUser *user; 
    414416                 
    415                 if ( [users count] == 0 ) return; 
    416                 else if ( [users count] == 1 ) user = [users anyObject]; 
     417                if( [users count] == 0 ) return; 
     418                else if( [users count] == 1 ) user = [users anyObject]; 
    417419                else { 
    418420                        [self _validateToolbar]; 
     
    482484        BOOL accepted = NO; 
    483485 
    484         if ( [sender tag] ) 
     486        if( [sender tag] ) 
    485487                accepted = YES; 
    486488 
    487489        BOOL alwaysAccept = NO; 
    488490 
    489         if ( [publicKeyAlwaysAccept state] == NSOnState ) 
     491        if( [publicKeyAlwaysAccept state] == NSOnState ) 
    490492                alwaysAccept = YES; 
    491493 
     
    494496        [publicKeyVerification orderOut:nil]; 
    495497 
    496         if ( [_publicKeyRequestQueue count] ) { 
     498        if( [_publicKeyRequestQueue count] ) { 
    497499                NSNotification *note = [_publicKeyRequestQueue anyObject]; 
    498500 
    499                 if ( note ) { 
     501                if( note ) { 
    500502                        [_publicKeyRequestQueue removeObject:note]; 
    501503                        [[NSNotificationCenter defaultCenter] postNotification:note]; 
     
    513515        int row = [userSelectionTable selectedRow]; 
    514516         
    515         if ( [sender tag] || row == -1 ) {  
     517        if( [sender tag] || row == -1 ) {  
    516518                [_userSelectionPossibleUsers release]; 
    517519                _userSelectionPossibleUsers = nil; 
     
    533535        id info = nil; 
    534536 
    535         while( ( info = [enumerator nextObject] ) ) 
    536                 [ret addObject:[info objectForKey:@"connection"]]; 
    537  
    538         return [[ret retain] autorelease]; 
     537        while( ( info = [enumerator nextObject] ) ) { 
     538                MVChatConnection *connection = [info objectForKey:@"connection"]; 
     539                if( connection ) [ret addObject:connection]; 
     540        } 
     541 
     542        return ret; 
    539543} 
    540544 
     
    545549 
    546550        while( ( info = [enumerator nextObject] ) ) 
    547                 if( [[info objectForKey:@"connection"] isConnected] ) 
    548                         [ret addObject:[info objectForKey:@"connection"]]; 
    549  
    550         return [[ret retain] autorelease]; 
     551                MVChatConnection *connection = [info objectForKey:@"connection"]; 
     552                if( [connection isConnected] ) 
     553                        [ret addObject:connection]; 
     554 
     555        return ret; 
    551556} 
    552557 
    553558- (MVChatConnection *) connectionForServerAddress:(NSString *) address { 
    554         MVChatConnection *ret = nil; 
    555559        NSEnumerator *enumerator = [_bookmarks objectEnumerator]; 
    556560        id info = nil; 
    557561 
    558562        while( ( info = [enumerator nextObject] ) ) { 
    559                 if( [[(MVChatConnection *)[info objectForKey:@"connection"] server] compare:address options:( NSCaseInsensitiveSearch | NSLiteralSearch | NSBackwardsSearch | NSAnchoredSearch )] == NSOrderedSame ) { 
    560                         ret = [info objectForKey:@"connection"]; 
    561                         if( [ret isConnected] ) return ret; 
    562                 } 
    563         } 
    564  
    565         return ret; 
     563                MVChatConnection *connection = [info objectForKey:@"connection"]; 
     564                if( [[connection server] compare:address options:( NSCaseInsensitiveSearch | NSLiteralSearch | NSBackwardsSearch | NSAnchoredSearch )] == NSOrderedSame ) { 
     565                        if( [connection isConnected] ) 
     566                                return connection; 
     567                } 
     568        } 
     569 
     570        return nil; 
    566571} 
    567572 
     
    990995        } else if( view == newJoinRooms ) { 
    991996                return [_joinRooms objectAtIndex:row]; 
    992         } else if ( view == userSelectionTable ) { 
     997        } else if( view == userSelectionTable ) { 
    993998                MVChatUser *user = [_userSelectionPossibleUsers objectAtIndex:row]; 
    994999                 
     
    15121517                        KAIgnoreRule *rule = nil; 
    15131518 
    1514                         while( ( rule = [ie nextObject] ) ) 
    1515                                 if( [rule isPermanent] ) 
    1516                                         [permIgnores addObject:[NSKeyedArchiver archivedDataWithRootObject:rule]]; 
     1519                        while( ( rule = [ie nextObject] ) ) { 
     1520                                if( [rule isPermanent] ) { 
     1521                                        NSData *archive = [NSKeyedArchiver archivedDataWithRootObject:rule]; 
     1522                                        if( archive ) [permIgnores addObject:archive]; 
     1523                                } 
     1524                        } 
    15171525 
    15181526                        if( [permIgnores count] ) [data setObject:permIgnores forKey:@"ignores"]; 
     
    15691577                NSData *rule = nil; 
    15701578 
    1571                 while( ( rule = [ie nextObject] ) ) 
    1572                         [permIgnores addObject:[NSKeyedUnarchiver unarchiveObjectWithData:rule]]; 
     1579                while( ( rule = [ie nextObject] ) ) { 
     1580                        NSData *archive = [NSKeyedUnarchiver unarchiveObjectWithData:rule]; 
     1581                        if( archive ) [permIgnores addObject:archive]; 
     1582                } 
    15731583 
    15741584                [info setObject:permIgnores forKey:@"ignores"]; 
  • trunk/Controllers/MVFileTransferController.m

    r3325 r3346  
    267267 
    268268- (void) addFileTransfer:(id) transfer { 
    269         NSEnumerator *enumerator = nil; 
     269        NSParameterAssert( transfer != nil ); 
     270 
     271        NSEnumerator *enumerator = [_transferStorage objectEnumerator]; 
    270272        NSMutableDictionary *info = nil; 
    271         NSParameterAssert( transfer != nil ); 
    272  
    273         enumerator = [_transferStorage objectEnumerator]; 
    274273        while( ( info = [enumerator nextObject] ) ) 
    275274                if( [[info objectForKey:@"transfer"] isEqualTo:transfer] ) 
  • trunk/Models/JVSQLChatTranscript.m

    r3345 r3346  
    66#import "NSAttributedStringMoreAdditions.h" 
    77 
    8 #import <Foundation/NSDebug.h> 
    98#import <sys/stat.h> 
    109#import <unistd.h> 
  • trunk/Views/JVMarkedScroller.m

    r3259 r3346  
    113113 
    114114                if( ! NSPointInRect( point, knobRect ) ) { 
    115                         if( mark.color != nil ) { 
     115                        if( mark.color ) { 
    116116                                NSBezierPath *line = [NSBezierPath bezierPath]; 
    117117                                [line moveToPoint:point];