From 54427fd5940ea245903b51ab91b714b77fc4309c Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Tue, 17 Nov 2020 20:47:50 +0000 Subject: [PATCH] Make sure deleted text items are removed from view and selection. Fixes https://gitlab.com/kicad/code/kicad/issues/6407 --- common/view/view_group.cpp | 5 +++-- pcbnew/board_item.cpp | 2 +- pcbnew/dialogs/dialog_edit_footprint_for_fp_editor.cpp | 10 +++++++++- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/common/view/view_group.cpp b/common/view/view_group.cpp index 281672a84b..e1fce2e848 100644 --- a/common/view/view_group.cpp +++ b/common/view/view_group.cpp @@ -114,12 +114,13 @@ void VIEW_GROUP::ViewDraw( int aLayer, VIEW* aView ) const KIGFX::GAL* gal = aView->GetGAL(); PAINTER* painter = aView->GetPainter(); bool isSelection = m_layer == LAYER_SELECT_OVERLAY; - const auto drawList = updateDrawList(); + + const std::vector drawList = updateDrawList(); std::unordered_map> layer_item_map; // Build a list of layers used by the items in the group - for( auto item : drawList ) + for( VIEW_ITEM* item : drawList ) { int item_layers[VIEW::VIEW_MAX_LAYERS], item_layers_count; item->ViewGetLayers( item_layers, item_layers_count ); diff --git a/pcbnew/board_item.cpp b/pcbnew/board_item.cpp index 16860f3d32..2aef9f8944 100644 --- a/pcbnew/board_item.cpp +++ b/pcbnew/board_item.cpp @@ -112,7 +112,7 @@ void BOARD_ITEM::ViewGetLayers( int aLayers[], int& aCount ) const void BOARD_ITEM::DeleteStructure() { - auto parent = GetParent(); + BOARD_ITEM_CONTAINER* parent = GetParent(); if( parent ) parent->Remove( this ); diff --git a/pcbnew/dialogs/dialog_edit_footprint_for_fp_editor.cpp b/pcbnew/dialogs/dialog_edit_footprint_for_fp_editor.cpp index a28b177395..fa49da6df4 100644 --- a/pcbnew/dialogs/dialog_edit_footprint_for_fp_editor.cpp +++ b/pcbnew/dialogs/dialog_edit_footprint_for_fp_editor.cpp @@ -44,6 +44,8 @@ #include "3d_cache/dialogs/panel_prev_3d.h" #include "3d_cache/dialogs/3d_cache_dialogs.h" #include +#include +#include #include @@ -632,9 +634,15 @@ bool DIALOG_FOOTPRINT_FP_EDITOR::TransferDataFromWindow() } } - // Remove items from m_footprint graphic list: + // Remove text items: + SELECTION_TOOL* selTool = m_frame->GetToolManager()->GetTool(); + for( FP_TEXT* item: items_to_remove ) + { + selTool->RemoveItemFromSel( item ); + view->Remove( item ); item->DeleteStructure(); + } // if there are still grid table entries, create new texts for them while( i < m_texts->size() )