7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-21 00:21:25 +00:00

Change deleting for-range loop to while loop

It seem that the iterator may be invalidated in the loop.
By always taking the first element and looping until empty, we avoid the issue

Fixes https://gitlab.com/kicad/code/kicad/-/issues/20283
This commit is contained in:
Lucas Dumont 2025-03-08 22:18:27 +01:00 committed by Seth Hillbrand
parent c05cc345f3
commit 3ddaa24775

View File

@ -578,10 +578,11 @@ bool DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::TransferDataFromWindow()
// Update fields
m_frame->GetToolManager()->RunAction( PCB_ACTIONS::selectionClear );
for( PCB_FIELD* existing : m_footprint->GetFields() )
while( !m_footprint->GetFields().empty() )
{
m_footprint->Remove( existing );
PCB_FIELD* existing = m_footprint->GetFields().front();
view->Remove( existing );
m_footprint->Remove( existing );
delete existing;
}