mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 02:10:48 +00:00
Fix code whaich produced uninitialised space in the cells array.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@20905 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
52ff2b181d
commit
184a0e3da3
2 changed files with 39 additions and 16 deletions
13
ChangeLog
13
ChangeLog
|
@ -1,4 +1,15 @@
|
|||
2005-03-13 Richard Frith-Macdoanld <rfm@gnu.org>
|
||||
2005-03-14 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSMatrix.m:
|
||||
([removeRow:]) set column counts to zero if all rows are removed
|
||||
([removeColumn:]) set row counts to zero if all columns are removed
|
||||
([_renewRows:columns:rowSpace:colSpace:]) initialise all columns of
|
||||
any newly created rows (up to _maxCols) rather than just the number
|
||||
specified by the method argument. Otherwise we get uninitialised
|
||||
columns in the matrix which will cause a crash when they are used.
|
||||
Fixes bug #12299
|
||||
|
||||
2005-03-13 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Headers/AppKit/NSGraphics.h: Fix prototype for stricter compiler.
|
||||
* Source/Functions.m: ditto
|
||||
|
|
|
@ -634,6 +634,11 @@ static SEL getSel;
|
|||
_numCols--;
|
||||
_maxCols--;
|
||||
|
||||
if (_maxCols == 0)
|
||||
{
|
||||
_numRows = _maxRows = 0;
|
||||
}
|
||||
|
||||
if (column == _selectedColumn)
|
||||
{
|
||||
_selectedCell = nil;
|
||||
|
@ -680,6 +685,11 @@ static SEL getSel;
|
|||
_maxRows--;
|
||||
_numRows--;
|
||||
|
||||
if (_maxRows == 0)
|
||||
{
|
||||
_numCols = _maxCols = 0;
|
||||
}
|
||||
|
||||
if (row == _selectedRow)
|
||||
{
|
||||
_selectedCell = nil;
|
||||
|
@ -2204,7 +2214,7 @@ static SEL getSel;
|
|||
// we clear the existing selection
|
||||
// unless the Alternate or Shift keys have been pressed.
|
||||
if (!(mouseDownFlags & NSShiftKeyMask)
|
||||
&& !(mouseDownFlags & NSAlternateKeyMask))
|
||||
&& !(mouseDownFlags & NSAlternateKeyMask))
|
||||
{
|
||||
[self deselectAllCells];
|
||||
}
|
||||
|
@ -3591,18 +3601,19 @@ static SEL getSel;
|
|||
int end = row - 1;
|
||||
|
||||
_cells = NSZoneRealloc(_myZone, _cells, row * sizeof(id*));
|
||||
_selectedCells = NSZoneRealloc(_myZone, _selectedCells, row * sizeof(BOOL*));
|
||||
_selectedCells
|
||||
= NSZoneRealloc(_myZone, _selectedCells, row * sizeof(BOOL*));
|
||||
|
||||
/* Allocate the new rows and fill them */
|
||||
for (i = oldMaxR; i < row; i++)
|
||||
{
|
||||
_cells[i] = NSZoneMalloc(_myZone, col * sizeof(id));
|
||||
_cells[i] = NSZoneMalloc(_myZone, _maxCols * sizeof(id));
|
||||
_selectedCells[i] = NSZoneMalloc(GSAtomicMallocZone(),
|
||||
col * sizeof(BOOL));
|
||||
_maxCols * sizeof(BOOL));
|
||||
|
||||
if (i == end)
|
||||
{
|
||||
for (j = 0; j < col; j++)
|
||||
for (j = 0; j < _maxCols; j++)
|
||||
{
|
||||
_cells[i][j] = nil;
|
||||
_selectedCells[i][j] = NO;
|
||||
|
@ -3610,7 +3621,7 @@ static SEL getSel;
|
|||
{
|
||||
rowSpace--;
|
||||
}
|
||||
else
|
||||
else if (i < col)
|
||||
{
|
||||
(*mkImp)(self, mkSel, i, j);
|
||||
}
|
||||
|
@ -3618,11 +3629,14 @@ static SEL getSel;
|
|||
}
|
||||
else
|
||||
{
|
||||
for (j = 0; j < col; j++)
|
||||
for (j = 0; j < _maxCols; j++)
|
||||
{
|
||||
_cells[i][j] = nil;
|
||||
_selectedCells[i][j] = NO;
|
||||
(*mkImp)(self, mkSel, i, j);
|
||||
if (i < col)
|
||||
{
|
||||
(*mkImp)(self, mkSel, i, j);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3665,9 +3679,9 @@ static SEL getSel;
|
|||
NSCell *aCell = _cells[i][j];
|
||||
|
||||
if ([aCell isEnabled]
|
||||
&& ([aCell state] != state || [aCell isHighlighted] != highlight
|
||||
|| (state == NSOffState && _selectedCells[i][j] != NO)
|
||||
|| (state != NSOffState && _selectedCells[i][j] == NO)))
|
||||
&& ([aCell state] != state || [aCell isHighlighted] != highlight
|
||||
|| (state == NSOffState && _selectedCells[i][j] != NO)
|
||||
|| (state != NSOffState && _selectedCells[i][j] == NO)))
|
||||
{
|
||||
[aCell setState: state];
|
||||
|
||||
|
@ -3696,8 +3710,7 @@ static SEL getSel;
|
|||
{
|
||||
if ([_cells[row][j] isEnabled] && [_cells[row][j] isSelectable])
|
||||
{
|
||||
_selectedCell = [self selectTextAtRow: row
|
||||
column: j];
|
||||
_selectedCell = [self selectTextAtRow: row column: j];
|
||||
_selectedRow = row;
|
||||
_selectedColumn = j;
|
||||
return YES;
|
||||
|
@ -3711,8 +3724,7 @@ static SEL getSel;
|
|||
{
|
||||
if ([_cells[i][j] isEnabled] && [_cells[i][j] isSelectable])
|
||||
{
|
||||
_selectedCell = [self selectTextAtRow: i
|
||||
column: j];
|
||||
_selectedCell = [self selectTextAtRow: i column: j];
|
||||
_selectedRow = i;
|
||||
_selectedColumn = j;
|
||||
return YES;
|
||||
|
|
Loading…
Reference in a new issue