diff --git a/docs/changes.txt b/docs/changes.txt index 290420065b..88a119573b 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -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: diff --git a/src/generic/gridsel.cpp b/src/generic/gridsel.cpp index c6cf59f389..3f0f3f596b 100644 --- a/src/generic/gridsel.cpp +++ b/src/generic/gridsel.cpp @@ -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) {