From 64357fde0d96d34bfb82d3a9d775de5cd584d722 Mon Sep 17 00:00:00 2001 From: Randall Luecke Date: Thu, 4 Mar 2010 14:04:15 -0500 Subject: [PATCH] Fixed bug where you could drag non-existant rows. Closes #520 and #521 --- AppKit/CPTableView.j | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/AppKit/CPTableView.j b/AppKit/CPTableView.j index 14d85b370..fdc58db0d 100644 --- a/AppKit/CPTableView.j +++ b/AppKit/CPTableView.j @@ -2553,7 +2553,7 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5; // if the table has drag support then we use mouseUp to select a single row. // otherwise it uses mouse down. - if (!(_implementedDataSourceMethods & CPTableViewDataSource_tableView_writeRowsWithIndexes_toPasteboard_)) + if (row >=0 && !(_implementedDataSourceMethods & CPTableViewDataSource_tableView_writeRowsWithIndexes_toPasteboard_)) [self _updateSelectionWithMouseAtRow:row]; [[self window] makeFirstResponder:self]; @@ -2583,7 +2583,7 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5; // or we're dragging from selected rows and we haven't begun a drag session if(!_isSelectingSession && _implementedDataSourceMethods & CPTableViewDataSource_tableView_writeRowsWithIndexes_toPasteboard_) { - if ((ABS(_startTrackingPoint.x - aPoint.x) > 3 || (_verticalMotionCanDrag && ABS(_startTrackingPoint.y - aPoint.y) > 3)) || + if (row >= 0 && (ABS(_startTrackingPoint.x - aPoint.x) > 3 || (_verticalMotionCanDrag && ABS(_startTrackingPoint.y - aPoint.y) > 3)) || ([_selectedRowIndexes containsIndex:row])) { if ([_selectedRowIndexes containsIndex:row]) @@ -2641,8 +2641,8 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5; } _isSelectingSession = YES; - [self _updateSelectionWithMouseAtRow:row]; - [self _updateSelectionWithMouseAtRow:[self rowAtPoint:aPoint]]; + if(row >= 0) + [self _updateSelectionWithMouseAtRow:row]; if ((_implementedDataSourceMethods & CPTableViewDataSource_tableView_setObjectValue_forTableColumn_row_) && !_trackingPointMovedOutOfClickSlop)