From a9b2234f4e8bd07cdb94abbddf0524d23e3d3214 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Tue, 4 Apr 2023 17:04:24 +0100 Subject: [PATCH] Use a softer Reset for grid settings. Fixes https://gitlab.com/kicad/code/kicad/issues/14458 --- common/dialogs/dialog_grid_settings.cpp | 2 +- eeschema/tools/ee_selection_tool.cpp | 11 +++++------ pcbnew/tools/pcb_selection_tool.cpp | 24 +++++++++--------------- 3 files changed, 15 insertions(+), 22 deletions(-) diff --git a/common/dialogs/dialog_grid_settings.cpp b/common/dialogs/dialog_grid_settings.cpp index 6259f41d7c..efe303ed89 100644 --- a/common/dialogs/dialog_grid_settings.cpp +++ b/common/dialogs/dialog_grid_settings.cpp @@ -127,7 +127,7 @@ bool DIALOG_GRID_SETTINGS::TransferDataFromWindow() // Notify TOOLS TOOL_MANAGER* mgr = m_parent->GetToolManager(); - mgr->ResetTools( TOOL_BASE::MODEL_RELOAD ); + mgr->ResetTools( TOOL_BASE::REDRAW ); // Notify GAL mgr->RunAction( ACTIONS::gridPreset, true, static_cast( gridCfg.last_size_idx ) ); diff --git a/eeschema/tools/ee_selection_tool.cpp b/eeschema/tools/ee_selection_tool.cpp index 25b7632756..e0242386b9 100644 --- a/eeschema/tools/ee_selection_tool.cpp +++ b/eeschema/tools/ee_selection_tool.cpp @@ -298,11 +298,15 @@ void EE_SELECTION_TOOL::Reset( RESET_REASON aReason ) { m_frame = getEditFrame(); - if( aReason == TOOL_BASE::MODEL_RELOAD ) + if( aReason != TOOL_BASE::REDRAW ) { // Remove pointers to the selected items from containers without changing their // properties (as they are already deleted while a new sheet is loaded) m_selection.Clear(); + } + + if( aReason == TOOL_BASE::MODEL_RELOAD ) + { getView()->GetPainter()->GetSettings()->SetHighlight( false ); SYMBOL_EDIT_FRAME* symbolEditFrame = dynamic_cast( m_frame ); @@ -319,11 +323,6 @@ void EE_SELECTION_TOOL::Reset( RESET_REASON aReason ) m_isSymbolViewer = symbolViewerFrame != nullptr; } } - else - { - // Restore previous properties of selected items and remove them from containers - ClearSelection(); - } // Reinsert the VIEW_GROUP, in case it was removed from the VIEW getView()->Remove( &m_selection ); diff --git a/pcbnew/tools/pcb_selection_tool.cpp b/pcbnew/tools/pcb_selection_tool.cpp index 4512074d41..f5ba7491f2 100644 --- a/pcbnew/tools/pcb_selection_tool.cpp +++ b/pcbnew/tools/pcb_selection_tool.cpp @@ -211,24 +211,18 @@ void PCB_SELECTION_TOOL::Reset( RESET_REASON aReason ) m_frame = getEditFrame(); m_isFootprintEditor = m_frame->IsType( FRAME_FOOTPRINT_EDITOR ); - if( m_enteredGroup ) - ExitGroup(); + if( aReason != TOOL_BASE::REDRAW ) + { + if( m_enteredGroup ) + ExitGroup(); + + // Deselect any item being currently in edit, to avoid unexpected behavior and remove + // pointers to the selected items from containers. + ClearSelection( true ); + } if( aReason == TOOL_BASE::MODEL_RELOAD ) - { - // Deselect any item being currently in edit, to avoid unexpected behavior - // and remove pointers to the selected items from containers - // without changing their properties (as they are already deleted - // while a new board is loaded) - ClearSelection( true ); - getView()->GetPainter()->GetSettings()->SetHighlight( false ); - } - else if ( aReason != TOOL_BASE::REDRAW ) - { - // Restore previous properties of selected items and remove them from containers - ClearSelection( true ); - } // Reinsert the VIEW_GROUP, in case it was removed from the VIEW view()->Remove( &m_selection );