Skip to content

Commit

Permalink
Don't crash when removing a row while editing it
Browse files Browse the repository at this point in the history
  • Loading branch information
gnachman committed Oct 11, 2011
1 parent aa32fab commit b7a7900
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions TriggerController.m
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ - (NSArray *)triggers

- (void)setTrigger:(NSDictionary *)trigger forRow:(NSInteger)rowIndex
{
// Stop editing. A reload while editing crashes.
[tableView_ reloadData];
NSMutableArray *triggers = [[[self triggers] mutableCopy] autorelease];
if (rowIndex < 0) {
assert(trigger);
Expand Down Expand Up @@ -151,6 +153,10 @@ - (NSInteger)numberOfRowsInTableView:(NSTableView *)aTableView
- (id)tableView:(NSTableView *)aTableView
objectValueForTableColumn:(NSTableColumn *)aTableColumn
row:(NSInteger)rowIndex {
if (rowIndex >= [self numberOfRowsInTableView:aTableView]) {
// Sanity check.
return nil;
}
NSDictionary *trigger = [[self triggers] objectAtIndex:rowIndex];
if (aTableColumn == regexColumn_) {
return [trigger objectForKey:kTriggerRegexKey];
Expand Down

0 comments on commit b7a7900

Please sign in to comment.