Fix preserving selection when changing selection mode in wxGrid

The loop over the existing selection was buggy and took into account only one
corner of the block instead of the entire block and also skipped some blocks
entirely.

Closes #17572.
This commit is contained in:
jonkraber 2016-06-18 18:12:52 +02:00 committed by Vadim Zeitlin
parent 9c2076b79f
commit 96ef6ea293
2 changed files with 6 additions and 4 deletions

View File

@ -90,6 +90,7 @@ All (GUI):
- Add wxListCtrl::SetHeaderAttr().
- Add support for using markup in wxDataViewCtrl text items.
- Implement auto complete in generic wxSearchCtrl (Eric Jensen).
- Fix preserving selection when changing selection mode in wxGrid (jonkraber).
wxGTK:

View File

@ -144,14 +144,15 @@ void wxGridSelection::SetSelectionMode( wxGrid::wxGridSelectionModes selmode )
}
// Note that m_blockSelectionTopLeft's size may be changing!
for (n = 0; n < m_blockSelectionTopLeft.GetCount(); n++)
for ( n = m_blockSelectionTopLeft.GetCount(); n > 0; )
{
n--;
wxGridCellCoords& coords = m_blockSelectionTopLeft[n];
int topRow = coords.GetRow();
int leftCol = coords.GetCol();
coords = m_blockSelectionBottomRight[n];
int bottomRow = coords.GetRow();
int rightCol = coords.GetCol();
wxGridCellCoords& coords2 = m_blockSelectionBottomRight[n];
int bottomRow = coords2.GetRow();
int rightCol = coords2.GetCol();
if (selmode == wxGrid::wxGridSelectRows)
{