Fix fatal bug in wxGridSelection::DeselectBlock()
The selBlock reference could be used after the vector invalidation, which resulted in using the wrong vector element at best and could probably lead to a crash at worst. Don't use it after invalidating the vector any longer. This notably fixes a bug in row-or-column selection mode where the grid wasn't updated visually after modifying its selection by deselecting a single cell as soon as there were more than one selected row or column.
This commit is contained in:
@@ -290,14 +290,15 @@ wxGridSelection::DeselectBlock(const wxGridBlockCoords& block,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove the block
|
const wxGridBlockDiffResult result =
|
||||||
|
selBlock.Difference(canonicalizedBlock, splitOrientation);
|
||||||
|
|
||||||
|
// remove the block (note that selBlock, being a reference, is
|
||||||
|
// invalidated here and can't be used any more below)
|
||||||
m_selection.erase(m_selection.begin() + n);
|
m_selection.erase(m_selection.begin() + n);
|
||||||
n--;
|
n--;
|
||||||
count--;
|
count--;
|
||||||
|
|
||||||
wxGridBlockDiffResult result =
|
|
||||||
selBlock.Difference(canonicalizedBlock, splitOrientation);
|
|
||||||
|
|
||||||
for ( int i = 0; i < 2; ++i )
|
for ( int i = 0; i < 2; ++i )
|
||||||
{
|
{
|
||||||
const wxGridBlockCoords& part = result.m_parts[i];
|
const wxGridBlockCoords& part = result.m_parts[i];
|
||||||
|
Reference in New Issue
Block a user