Clear flags before depending on them.

(While at first it may look like any item with the flag set
is going to get deleted anyway, if an undo happens then we
end up with table cells with the STRUCT_DELETED flag already
set.)

Fixes https://gitlab.com/kicad/code/kicad/-/issues/17487
This commit is contained in:
Jeff Young 2024-03-20 17:55:33 +00:00
parent 90eed8b4b6
commit 7bdf1c7e0f
1 changed files with 6 additions and 0 deletions

View File

@ -327,6 +327,9 @@ protected:
T_TABLE* table = static_cast<T_TABLE*>( selection[0]->GetParent() ); T_TABLE* table = static_cast<T_TABLE*>( selection[0]->GetParent() );
std::vector<int> deleted; std::vector<int> deleted;
for( T_TABLECELL* cell : table->GetCells() )
cell->ClearFlags( STRUCT_DELETED );
for( int row = 0; row < table->GetRowCount(); ++row ) for( int row = 0; row < table->GetRowCount(); ++row )
{ {
bool deleteRow = false; bool deleteRow = false;
@ -401,6 +404,9 @@ protected:
T_TABLE* table = static_cast<T_TABLE*>( selection[0]->GetParent() ); T_TABLE* table = static_cast<T_TABLE*>( selection[0]->GetParent() );
std::vector<int> deleted; std::vector<int> deleted;
for( T_TABLECELL* cell : table->GetCells() )
cell->ClearFlags( STRUCT_DELETED );
for( int col = 0; col < table->GetColCount(); ++col ) for( int col = 0; col < table->GetColCount(); ++col )
{ {
bool deleteColumn = false; bool deleteColumn = false;