Fix wxGrid::PosToLinePos() in presence of hidden rows or columns.
The optimization of the binary search inside this function failed if any rows/columns were hidden and so were of zero size. See #14133. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72490 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
bc7d2e9dd4
commit
5bce3d5701
@ -6502,8 +6502,8 @@ wxGridCellCoords wxGrid::XYToCell(int x, int y) const
|
|||||||
|
|
||||||
// compute row or column from some (unscrolled) coordinate value, using either
|
// compute row or column from some (unscrolled) coordinate value, using either
|
||||||
// m_defaultRowHeight/m_defaultColWidth or binary search on array of
|
// m_defaultRowHeight/m_defaultColWidth or binary search on array of
|
||||||
// m_rowBottoms/m_colRights to do it quickly (linear search shouldn't be used
|
// m_rowBottoms/m_colRights to do it quickly in O(log n) time.
|
||||||
// for large grids)
|
// NOTE: This may not work correctly for reordered columns.
|
||||||
int wxGrid::PosToLinePos(int coord,
|
int wxGrid::PosToLinePos(int coord,
|
||||||
bool clipToMinMax,
|
bool clipToMinMax,
|
||||||
const wxGridOperations& oper) const
|
const wxGridOperations& oper) const
|
||||||
@ -6531,26 +6531,11 @@ int wxGrid::PosToLinePos(int coord,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// adjust maxPos before starting the binary search
|
// binary search is quite efficient and we can't really make any assumptions
|
||||||
if ( maxPos >= numLines )
|
// on where to start here since row and columns could be of size 0 if they are
|
||||||
{
|
// hidden. While this could be made more efficient, some profiling will be
|
||||||
|
// necessary to determine if it really is a performance bottleneck
|
||||||
maxPos = numLines - 1;
|
maxPos = numLines - 1;
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if ( coord >= lineEnds[oper.GetLineAt(this, maxPos)])
|
|
||||||
{
|
|
||||||
minPos = maxPos;
|
|
||||||
const int minDist = oper.GetMinimalAcceptableLineSize(this);
|
|
||||||
if ( minDist )
|
|
||||||
maxPos = coord / minDist;
|
|
||||||
else
|
|
||||||
maxPos = numLines - 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( maxPos >= numLines )
|
|
||||||
maxPos = numLines - 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// check if the position is beyond the last column
|
// check if the position is beyond the last column
|
||||||
const int lineAtMaxPos = oper.GetLineAt(this, maxPos);
|
const int lineAtMaxPos = oper.GetLineAt(this, maxPos);
|
||||||
|
Loading…
Reference in New Issue
Block a user