From 7bdf1c7e0fa5c243b12085bb920bf5f81c634f67 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Wed, 20 Mar 2024 17:55:33 +0000 Subject: [PATCH] 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 --- include/tool/edit_table_tool_base.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/tool/edit_table_tool_base.h b/include/tool/edit_table_tool_base.h index b2ac42f666..47c9b11714 100644 --- a/include/tool/edit_table_tool_base.h +++ b/include/tool/edit_table_tool_base.h @@ -327,6 +327,9 @@ protected: T_TABLE* table = static_cast( selection[0]->GetParent() ); std::vector deleted; + for( T_TABLECELL* cell : table->GetCells() ) + cell->ClearFlags( STRUCT_DELETED ); + for( int row = 0; row < table->GetRowCount(); ++row ) { bool deleteRow = false; @@ -401,6 +404,9 @@ protected: T_TABLE* table = static_cast( selection[0]->GetParent() ); std::vector deleted; + for( T_TABLECELL* cell : table->GetCells() ) + cell->ClearFlags( STRUCT_DELETED ); + for( int col = 0; col < table->GetColCount(); ++col ) { bool deleteColumn = false;