Don't use uninitialized variables in wxGrid::AutoSize().
The code in wxGrid::AutoSizeColOrRow() was using uninitialized col/row variable if the grid had no rows/columns, resulting in assertion failures when trying to automatically size the columns of an empty grid. Do initialize them now and also remove duplicate assignments to the variables which never change inside the loop. Closes #12206. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@64885 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
3dea8ba7ac
commit
68abd97d19
@ -7865,24 +7865,29 @@ wxGrid::AutoSizeColOrRow(int colOrRow, bool setAsMin, wxGridDirection direction)
|
|||||||
HideCellEditControl();
|
HideCellEditControl();
|
||||||
SaveEditControlValue();
|
SaveEditControlValue();
|
||||||
|
|
||||||
// initialize both of them just to avoid compiler warnings
|
// initialize both of them just to avoid compiler warnings even if only
|
||||||
int row = -1,
|
// really needs to be initialized here
|
||||||
|
int row,
|
||||||
|
col;
|
||||||
|
if ( column )
|
||||||
|
{
|
||||||
|
row = -1;
|
||||||
|
col = colOrRow;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
row = colOrRow;
|
||||||
col = -1;
|
col = -1;
|
||||||
|
}
|
||||||
|
|
||||||
wxCoord extent, extentMax = 0;
|
wxCoord extent, extentMax = 0;
|
||||||
int max = column ? m_numRows : m_numCols;
|
int max = column ? m_numRows : m_numCols;
|
||||||
for ( int rowOrCol = 0; rowOrCol < max; rowOrCol++ )
|
for ( int rowOrCol = 0; rowOrCol < max; rowOrCol++ )
|
||||||
{
|
{
|
||||||
if ( column )
|
if ( column )
|
||||||
{
|
|
||||||
row = rowOrCol;
|
row = rowOrCol;
|
||||||
col = colOrRow;
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
row = colOrRow;
|
|
||||||
col = rowOrCol;
|
col = rowOrCol;
|
||||||
}
|
|
||||||
|
|
||||||
// we need to account for the cells spanning multiple columns/rows:
|
// we need to account for the cells spanning multiple columns/rows:
|
||||||
// while they may need a lot of space, they don't need all of it in
|
// while they may need a lot of space, they don't need all of it in
|
||||||
|
Loading…
Reference in New Issue
Block a user