mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-05-19 19:33:47 +00:00
Fix ObjectTable crash on cell deselect after wxWidgets 3.3.2 upgrade (#13740)
GridCellSupportEditor::DoActivate dereferenced grid->GetSelectedBlocks().begin() without checking against end(). In wxWidgets 3.1.5 that range always contained at least one block; in 3.3.2 it is empty after the user deselects, and the dereference crashes inside wxGridBlockCoords::GetLeftCol(). Fall back to the (row, col) that triggered activation when the selection is empty, so the existing single-cell branch handles it. While here, drop a dead local_table cast that was never read.
This commit is contained in:
@@ -561,14 +561,23 @@ wxString GridCellSupportEditor::ms_stringValues[2] = { wxT(""), wxT("") };
|
|||||||
|
|
||||||
void GridCellSupportEditor::DoActivate(int row, int col, wxGrid* grid)
|
void GridCellSupportEditor::DoActivate(int row, int col, wxGrid* grid)
|
||||||
{
|
{
|
||||||
ObjectGrid* local_table = dynamic_cast<ObjectGrid*>(grid);
|
|
||||||
wxGridBlocks cell_array = grid->GetSelectedBlocks();
|
wxGridBlocks cell_array = grid->GetSelectedBlocks();
|
||||||
|
auto iter = cell_array.begin();
|
||||||
auto left_col = cell_array.begin()->GetLeftCol();
|
|
||||||
auto right_col = cell_array.begin()->GetRightCol();
|
int left_col, right_col, top_row, bottom_row;
|
||||||
auto top_row = cell_array.begin()->GetTopRow();
|
if (iter == cell_array.end()) {
|
||||||
auto bottom_row = cell_array.begin()->GetBottomRow();
|
// wxWidgets 3.3.x returns an empty range when nothing is selected;
|
||||||
|
// fall back to the cell that triggered activation so the single-cell
|
||||||
|
// branch below handles it.
|
||||||
|
left_col = right_col = col;
|
||||||
|
top_row = bottom_row = row;
|
||||||
|
} else {
|
||||||
|
left_col = iter->GetLeftCol();
|
||||||
|
right_col = iter->GetRightCol();
|
||||||
|
top_row = iter->GetTopRow();
|
||||||
|
bottom_row = iter->GetBottomRow();
|
||||||
|
}
|
||||||
|
|
||||||
if ((left_col == right_col) &&
|
if ((left_col == right_col) &&
|
||||||
(top_row == bottom_row)) {
|
(top_row == bottom_row)) {
|
||||||
wxGridCellBoolEditor::DoActivate(row, col, grid);
|
wxGridCellBoolEditor::DoActivate(row, col, grid);
|
||||||
|
|||||||
Reference in New Issue
Block a user