From 3996a490a144e2147624aff69ce6d5c07d77b60f Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Wed, 4 Sep 2019 11:46:18 +0100 Subject: [PATCH] Re-allocating a std::vector invalidates its iterators. When we add enough SHEET_PINs that the vector has to grow, it re-allocates the vector causing our for-loop to get its knickers tied in a knot. Fixes: lp:1842394 * https://bugs.launchpad.net/kicad/+bug/1842394 --- eeschema/tools/ee_selection_tool.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/eeschema/tools/ee_selection_tool.cpp b/eeschema/tools/ee_selection_tool.cpp index f21d8f2711..218a0e4532 100644 --- a/eeschema/tools/ee_selection_tool.cpp +++ b/eeschema/tools/ee_selection_tool.cpp @@ -690,6 +690,7 @@ bool EE_SELECTION_TOOL::selectMultiple() // Mark items within the selection box as selected std::vector selectedItems; + std::vector sheetPins; // Filter the view items based on the selection box BOX2I selectionBox = area.ViewBBox(); @@ -705,10 +706,12 @@ bool EE_SELECTION_TOOL::selectMultiple() int layer = pair.second; for( SCH_SHEET_PIN& pin : sheet->GetPins() ) - selectedItems.emplace_back( &pin, layer ); + sheetPins.emplace_back( KIGFX::VIEW::LAYER_ITEM_PAIR( &pin, layer ) ); } } + selectedItems.insert( selectedItems.end(), sheetPins.begin(), sheetPins.end() ); + int width = area.GetEnd().x - area.GetOrigin().x; int height = area.GetEnd().y - area.GetOrigin().y;