Avoid asserts when painting empty wxGridColLabelWindow
When the grid is empty, XToCol() has no choice but to return invalid index (because there are no valid ones) when it's called from the drawing code and passing such indices to GetColPos() results in an assert, which is fatal inside wxEVT_PAINT handler. Just short-circuit all this code by not doing anything in the case of empty grid. This is sloppy, but simpler and more robust than any alternatives. Closes #18629.
This commit is contained in:
@@ -1813,6 +1813,11 @@ void wxGridColLabelWindow::OnPaint( wxPaintEvent& WXUNUSED(event) )
|
||||
//
|
||||
// m_owner->PrepareDC( dc );
|
||||
|
||||
// Column indices become invalid when the grid is empty, so avoid doing
|
||||
// anything at all in this case.
|
||||
if ( m_owner->GetNumberCols() == 0 )
|
||||
return;
|
||||
|
||||
int x, y;
|
||||
wxGridWindow *gridWindow = IsFrozen() ? m_owner->m_frozenColGridWin :
|
||||
m_owner->m_gridWin;
|
||||
|
Reference in New Issue
Block a user