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
HideCellEditControl();
SaveEditControlValue();
- // initialize both of them just to avoid compiler warnings
- int row = -1,
+ // initialize both of them just to avoid compiler warnings even if only
+ // really needs to be initialized here
+ int row,
+ col;
+ if ( column )
+ {
+ row = -1;
+ col = colOrRow;
+ }
+ else
+ {
+ row = colOrRow;
col = -1;
+ }
wxCoord extent, extentMax = 0;
int max = column ? m_numRows : m_numCols;
for ( int rowOrCol = 0; rowOrCol < max; rowOrCol++ )
{
if ( column )
- {
row = rowOrCol;
- col = colOrRow;
- }
else
- {
- row = colOrRow;
col = rowOrCol;
- }
// 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