Changeset 5042

Show
Ignore:
Timestamp:
11/02/07 16:47:18 (9 months ago)
Author:
morris
Message:

Fix range exceptions in bookmarks

Edit ignores/highlights after add

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • WiredClient/trunk/WCPreferences.m

    r5015 r5042  
    585585        row = [_bookmarksTableView selectedRow]; 
    586586         
    587         if(row >= 0) { 
     587        if(row >= 0 && (NSUInteger) row < [[WCSettings objectForKey:WCBookmarks] count]) { 
    588588                bookmark = [WCSettings bookmarkAtIndex:row]; 
    589589                 
     
    642642        row = [_bookmarksTableView selectedRow]; 
    643643         
    644         if(row < 0
     644        if(row < 0 || (NSUInteger) row >= [[WCSettings objectForKey:WCBookmarks] count]
    645645                return; 
    646646         
     
    12931293                [_bookmarksTableView reloadData]; 
    12941294                 
    1295                 row = row == 0 ? 0 : row - 1; 
    1296                  
    1297                 if(row != [_bookmarksTableView selectedRow]) 
    1298                         [_bookmarksTableView selectRow:row byExtendingSelection:NO]; 
    1299                 else 
    1300                         [self _selectBookmark]; 
    1301  
    13021295                [[NSNotificationCenter defaultCenter] postNotificationName:WCBookmarksDidChange object:self]; 
    13031296        } 
     
    13241317        [WCSettings addHighlight:highlight]; 
    13251318 
     1319        row = [[WCSettings objectForKey:WCHighlights] count] - 1; 
     1320         
    13261321        [_highlightsTableView reloadData]; 
    1327         [_highlightsTableView selectRow:[[WCSettings objectForKey:WCHighlights] count] - 1 
    1328                                byExtendingSelection:NO]; 
     1322        [_highlightsTableView selectRow:row byExtendingSelection:NO]; 
     1323        [_highlightsTableView editColumn:0 row:row withEvent:NULL select:YES]; 
    13291324} 
    13301325 
     
    13581353                 
    13591354                [_highlightsTableView reloadData]; 
    1360                 [_highlightsTableView selectRow:row == 0 ? 0 : row - 1 byExtendingSelection:NO]; 
    13611355        } 
    13621356} 
     
    13661360- (IBAction)addIgnore:(id)sender { 
    13671361        NSDictionary    *ignore; 
     1362        NSInteger               row; 
    13681363         
    13691364        ignore = [NSDictionary dictionaryWithObjectsAndKeys: 
     
    13741369        [WCSettings addIgnore:ignore]; 
    13751370         
     1371        row = [[WCSettings objectForKey:WCIgnores] count] - 1; 
     1372 
    13761373        [_ignoresTableView reloadData]; 
    1377         [_ignoresTableView selectRow:[[WCSettings objectForKey:WCIgnores] count] - 1 
    1378                        byExtendingSelection:NO]; 
     1374        [_ignoresTableView selectRow:row byExtendingSelection:NO]; 
     1375        [_ignoresTableView editColumn:0 row:row withEvent:NULL select:YES]; 
    13791376} 
    13801377 
     
    14061403                 
    14071404                [WCSettings removeIgnoreAtIndex:row]; 
    1408                  
    14091405                [_ignoresTableView reloadData]; 
    1410                 [_ignoresTableView selectRow:row == 0 ? 0 : row - 1 byExtendingSelection:NO]; 
    14111406        } 
    14121407} 
     
    15421537                 
    15431538        if(tableView == _highlightsTableView) { 
    1544                 dictionary = [[WCSettings highlightAtIndex:row] mutableCopy]; 
    1545                  
    1546                 if(tableColumn == _highlightsPatternTableColumn) 
    1547                         [dictionary setObject:object forKey:WCHighlightsPattern]; 
    1548                  
    1549                 [WCSettings setHighlight:dictionary atIndex:row]; 
    1550                 [dictionary release]; 
     1539                if((NSUInteger) row < [[WCSettings objectForKey:WCHighlights] count]) { 
     1540                        dictionary = [[WCSettings highlightAtIndex:row] mutableCopy]; 
     1541                         
     1542                        if(tableColumn == _highlightsPatternTableColumn) 
     1543                                [dictionary setObject:object forKey:WCHighlightsPattern]; 
     1544                         
     1545                        [WCSettings setHighlight:dictionary atIndex:row]; 
     1546                        [dictionary release]; 
     1547                } 
    15511548        } 
    15521549        else if(tableView == _ignoresTableView) { 
    1553                 dictionary = [[WCSettings ignoreAtIndex:row] mutableCopy]; 
    1554                  
    1555                 if(tableColumn == _ignoresNickTableColumn) 
    1556                         [dictionary setObject:object forKey:WCIgnoresNick]; 
    1557                 else if(tableColumn == _ignoresLoginTableColumn) 
    1558                         [dictionary setObject:object forKey:WCIgnoresLogin]; 
    1559                 else if(tableColumn == _ignoresAddressTableColumn) 
    1560                         [dictionary setObject:object forKey:WCIgnoresAddress]; 
    1561          
    1562                 [WCSettings setIgnore:dictionary atIndex:row]; 
    1563                 [dictionary release]; 
     1550                if((NSUInteger) row < [[WCSettings objectForKey:WCIgnores] count]) { 
     1551                        dictionary = [[WCSettings ignoreAtIndex:row] mutableCopy]; 
     1552                         
     1553                        if(tableColumn == _ignoresNickTableColumn) 
     1554                                [dictionary setObject:object forKey:WCIgnoresNick]; 
     1555                        else if(tableColumn == _ignoresLoginTableColumn) 
     1556                                [dictionary setObject:object forKey:WCIgnoresLogin]; 
     1557                        else if(tableColumn == _ignoresAddressTableColumn) 
     1558                                [dictionary setObject:object forKey:WCIgnoresAddress]; 
     1559                 
     1560                        [WCSettings setIgnore:dictionary atIndex:row]; 
     1561                        [dictionary release]; 
     1562                } 
    15641563        } 
    15651564}