fixed crash in HitTest() with y position below the last line
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@11471 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -2361,6 +2361,8 @@ wxRect wxListMainWindow::GetLineHighlightRect(size_t line) const
|
|||||||
|
|
||||||
long wxListMainWindow::HitTestLine(size_t line, int x, int y) const
|
long wxListMainWindow::HitTestLine(size_t line, int x, int y) const
|
||||||
{
|
{
|
||||||
|
wxASSERT_MSG( line < GetItemCount(), _T("invalid line in HitTestLine") );
|
||||||
|
|
||||||
wxListLineData *ld = GetLine(line);
|
wxListLineData *ld = GetLine(line);
|
||||||
|
|
||||||
if ( ld->HasImage() && GetLineIconRect(line).Inside(x, y) )
|
if ( ld->HasImage() && GetLineIconRect(line).Inside(x, y) )
|
||||||
@@ -4105,18 +4107,22 @@ long wxListMainWindow::HitTest( int x, int y, int &flags )
|
|||||||
{
|
{
|
||||||
CalcUnscrolledPosition( x, y, &x, &y );
|
CalcUnscrolledPosition( x, y, &x, &y );
|
||||||
|
|
||||||
|
size_t count = GetItemCount();
|
||||||
|
|
||||||
if ( HasFlag(wxLC_REPORT) )
|
if ( HasFlag(wxLC_REPORT) )
|
||||||
{
|
{
|
||||||
size_t current = y / GetLineHeight();
|
size_t current = y / GetLineHeight();
|
||||||
|
if ( current < count )
|
||||||
|
{
|
||||||
flags = HitTestLine(current, x, y);
|
flags = HitTestLine(current, x, y);
|
||||||
if ( flags )
|
if ( flags )
|
||||||
return current;
|
return current;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else // !report
|
else // !report
|
||||||
{
|
{
|
||||||
// TODO: optimize it too! this is less simple than for report view but
|
// TODO: optimize it too! this is less simple than for report view but
|
||||||
// enumerating all items is still not a way to do it!!
|
// enumerating all items is still not a way to do it!!
|
||||||
size_t count = GetItemCount();
|
|
||||||
for ( size_t current = 0; current < count; current++ )
|
for ( size_t current = 0; current < count; current++ )
|
||||||
{
|
{
|
||||||
flags = HitTestLine(current, x, y);
|
flags = HitTestLine(current, x, y);
|
||||||
|
Reference in New Issue
Block a user