Avoid division by 0 in generic wxDataViewCtrl scrolling code
Apparently, ScrollTo() can be called when processing keyboard input in the control before its initial resize and hence before scrolling is initialized and in this case per-unit scroll units are still 0, so dividing by them is not a good idea. Just avoid scrolling in this case. Closes https://github.com/wxWidgets/wxWidgets/pull/1262
This commit is contained in:
parent
7a2d9d0d10
commit
2531780c3b
@ -3110,9 +3110,12 @@ void wxDataViewMainWindow::ScrollTo( int rows, int column )
|
||||
|
||||
int x, y;
|
||||
m_owner->GetScrollPixelsPerUnit( &x, &y );
|
||||
int sy = GetLineStart( rows )/y;
|
||||
|
||||
// Take care to not divide by 0 if we're somehow called before scrolling
|
||||
// parameters are initialized.
|
||||
int sy = y ? GetLineStart( rows )/y : -1;
|
||||
int sx = -1;
|
||||
if( column != -1 )
|
||||
if( column != -1 && x )
|
||||
{
|
||||
wxRect rect = GetClientRect();
|
||||
int colnum = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user