Eeschema: internal tidying of field editor ApplyData
Make a few things const (specficially the reference into
m_fieldStore - we should commit to not modifying that in this
function.
Also avoid a couple of needless string copies.
Also explicitly dereference the into a (non-const) reference at the outset.
For the whole if this function, comp is the same object and may not
be null (as it is used unchecked).
(cherry picked from commit edd94ce2d6
)
This commit is contained in:
parent
b93382831c
commit
473c41ddbf
|
@ -590,26 +590,29 @@ public:
|
|||
{
|
||||
for( unsigned i = 0; i < m_componentRefs.GetCount(); ++i )
|
||||
{
|
||||
SCH_COMPONENT* comp = m_componentRefs[ i ].GetComp();
|
||||
SCH_COMPONENT& comp = *m_componentRefs[i].GetComp();
|
||||
|
||||
m_frame->SetCurrentSheet( m_componentRefs[ i ].GetSheetPath() );
|
||||
m_frame->SaveCopyInUndoList( comp, UR_CHANGED, true );
|
||||
m_frame->SetCurrentSheet( m_componentRefs[i].GetSheetPath() );
|
||||
m_frame->SaveCopyInUndoList( &comp, UR_CHANGED, true );
|
||||
|
||||
std::map<wxString, wxString>& fieldStore = m_dataStore[ comp->GetTimeStamp() ];
|
||||
const std::map<wxString, wxString>& fieldStore = m_dataStore[comp.GetTimeStamp()];
|
||||
|
||||
for( std::pair<wxString, wxString> srcData : fieldStore )
|
||||
for( const std::pair<wxString, wxString> srcData : fieldStore )
|
||||
{
|
||||
wxString srcName = srcData.first;
|
||||
wxString srcValue = srcData.second;
|
||||
SCH_FIELD* destField = comp->FindField( srcName );
|
||||
const wxString& srcName = srcData.first;
|
||||
const wxString& srcValue = srcData.second;
|
||||
SCH_FIELD* destField = comp.FindField( srcName );
|
||||
|
||||
if( !destField && !srcValue.IsEmpty() )
|
||||
destField = comp->AddField( SCH_FIELD( comp->GetPosition(), -1, comp, srcName ) );
|
||||
{
|
||||
const auto compOrigin = comp.GetPosition();
|
||||
destField = comp.AddField( SCH_FIELD( compOrigin, -1, &comp, srcName ) );
|
||||
}
|
||||
|
||||
if( destField && !srcValue.IsEmpty() )
|
||||
destField->SetText( srcValue );
|
||||
else
|
||||
comp->RemoveField( srcName );
|
||||
comp.RemoveField( srcName );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue