Enforce valid drag column/row index in DoGridDragResize()

Add an assert to this function checking that the index is valid before
using it with wxGridOperations::GetLineStartPos(), and actually avoid
calling the function when this is not the case to avoid assertion
failures when wxEVT_GRID_CELL_LEFT_CLICK is handled in user code.

Also add comments clarifying the preconditions for calling various
drag-related functions.

Closes #19218.
This commit is contained in:
Vadim Zeitlin
2021-07-03 16:31:15 +01:00
parent e70be8f82b
commit 5cac8a6918
2 changed files with 15 additions and 4 deletions

View File

@@ -2951,6 +2951,8 @@ private:
wxGridWindow* gridWindow);
// Update the width/height of the column/row being drag-resized.
// Should be only called when m_dragRowOrCol != -1, i.e. dragging is
// actually in progress.
void DoGridDragResize(const wxPoint& position,
const wxGridOperations& oper,
wxGridWindow* gridWindow);
@@ -2989,6 +2991,8 @@ private:
void DoStartResizeRowOrCol(int col);
void DoStartMoveCol(int col);
// These functions should only be called when actually resizing/moving,
// i.e. m_dragRowOrCol and m_dragMoveCol, respectively, are valid.
void DoEndDragResizeRow(const wxMouseEvent& event, wxGridWindow *gridWindow);
void DoEndDragResizeCol(const wxMouseEvent& event, wxGridWindow *gridWindow);
void DoEndMoveCol(int pos);