Prevent errors from NSTableView number of rows changing, when there were no rows selected.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@19400 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Fred Kiefer 2004-05-25 17:47:12 +00:00
parent da5c975abe
commit cac2d857fa
2 changed files with 10 additions and 3 deletions

View file

@ -1,3 +1,8 @@
2004-05-25 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSTableView.m: (-noteNumberOfRowsChanged)
Made save against [_selectedRows lastIndex] returning NSNotFound.
2004-05-23 Quentin Mathe <qmathe@lub-internet.fr> 2004-05-23 Quentin Mathe <qmathe@lub-internet.fr>
* Source/NSWindow.m: Added a method -_windowView which returns the root * Source/NSWindow.m: Added a method -_windowView which returns the root

View file

@ -4313,15 +4313,17 @@ byExtendingSelection: (BOOL)flag
int row = [_selectedRows lastIndex]; int row = [_selectedRows lastIndex];
/* Check that all selected rows are in the new range of rows */ /* Check that all selected rows are in the new range of rows */
if (row >= _numberOfRows) if ((row != NSNotFound) && (row >= _numberOfRows))
{ {
[_selectedRows removeIndexesInRange: [_selectedRows removeIndexesInRange:
NSMakeRange(_numberOfRows, row - _numberOfRows)]; NSMakeRange(_numberOfRows, row - _numberOfRows)];
if (_selectedRow >= _numberOfRows) if (_selectedRow >= _numberOfRows)
{ {
if ([_selectedRows count] > 0) row = [_selectedRows lastIndex];
if (row != NSNotFound)
{ {
_selectedRow = [_selectedRows lastIndex]; _selectedRow = row;
} }
else else
{ {