Sync selection & selection flags after replacing fields.

This commit is contained in:
Jeff Young 2025-03-09 11:47:15 +00:00
parent 1f620e9cca
commit 0a3f14c855
2 changed files with 25 additions and 3 deletions

View File

@ -46,6 +46,8 @@
#include <panel_fp_properties_3d_model.h> #include <panel_fp_properties_3d_model.h>
#include <dialogs/panel_preview_3d_model.h> #include <dialogs/panel_preview_3d_model.h>
#include <dialog_footprint_properties.h> #include <dialog_footprint_properties.h>
#include <tool/tool_manager.h>
#include <tools/pcb_selection_tool.h>
int DIALOG_FOOTPRINT_PROPERTIES::m_page = 0; // remember the last open page during session int DIALOG_FOOTPRINT_PROPERTIES::m_page = 0; // remember the last open page during session
@ -501,6 +503,8 @@ bool DIALOG_FOOTPRINT_PROPERTIES::TransferDataFromWindow()
if( !m_itemsGrid->CommitPendingChanges() ) if( !m_itemsGrid->CommitPendingChanges() )
return false; return false;
KIGFX::PCB_VIEW* view = m_frame->GetCanvas()->GetView();
PCB_SELECTION_TOOL* selectionTool = m_frame->GetToolManager()->GetTool<PCB_SELECTION_TOOL>();
BOARD_COMMIT commit( m_frame ); BOARD_COMMIT commit( m_frame );
commit.Modify( m_footprint ); commit.Modify( m_footprint );
@ -555,6 +559,15 @@ bool DIALOG_FOOTPRINT_PROPERTIES::TransferDataFromWindow()
newField->SetOrdinal( ordinal++ ); newField->SetOrdinal( ordinal++ );
m_footprint->Add( newField ); m_footprint->Add( newField );
view->Add( newField );
if( newField->IsSelected() )
{
// The old copy was in the selection list, but this one is not. Remove the
// out-of-sync selection flag so we can re-add the field to the selection.
newField->ClearSelected();
selectionTool->AddItemToSel( newField, true );
}
} }
// Initialize masks clearances // Initialize masks clearances

View File

@ -531,6 +531,7 @@ bool DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::TransferDataFromWindow()
} }
KIGFX::PCB_VIEW* view = m_frame->GetCanvas()->GetView(); KIGFX::PCB_VIEW* view = m_frame->GetCanvas()->GetView();
PCB_SELECTION_TOOL* selectionTool = m_frame->GetToolManager()->GetTool<PCB_SELECTION_TOOL>();
BOARD_COMMIT commit( m_frame ); BOARD_COMMIT commit( m_frame );
commit.Modify( m_footprint ); commit.Modify( m_footprint );
@ -589,6 +590,14 @@ bool DIALOG_FOOTPRINT_PROPERTIES_FP_EDITOR::TransferDataFromWindow()
PCB_FIELD* newField = field.CloneField(); PCB_FIELD* newField = field.CloneField();
m_footprint->Add( newField ); m_footprint->Add( newField );
view->Add( newField ); view->Add( newField );
if( newField->IsSelected() )
{
// The old copy was in the selection list, but this one is not. Remove the
// out-of-sync selection flag so we can re-add the field to the selection.
newField->ClearSelected();
selectionTool->AddItemToSel( newField, true );
}
} }
LSET privateLayers; LSET privateLayers;