Remove side-effect of LIB_FIELD::SetText().
Fixes: lp:1800545 * https://bugs.launchpad.net/kicad/+bug/1800545
This commit is contained in:
parent
6888268f74
commit
c4cd81a906
|
@ -352,12 +352,7 @@ void LIB_PART::SetName( const wxString& aName )
|
|||
wxString validatedName = LIB_ID::FixIllegalChars( aName, LIB_ID::ID_SCH );
|
||||
m_libId.SetLibItemName( validatedName, false );
|
||||
|
||||
LIB_FIELD& valueField = GetValueField();
|
||||
|
||||
// LIB_FIELD::SetText() calls LIB_PART::SetName(),
|
||||
// the following if-clause is to break an infinite loop
|
||||
if( valueField.GetText() != validatedName )
|
||||
valueField.SetText( validatedName );
|
||||
GetValueField().SetText( validatedName );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -29,9 +29,11 @@
|
|||
|
||||
#include <dialog_lib_edit_text_base.h>
|
||||
#include <widgets/unit_binder.h>
|
||||
#include <lib_field.h>
|
||||
#include <class_libentry.h>
|
||||
#include <template_fieldnames.h>
|
||||
|
||||
class SCH_BASE_FRAME;
|
||||
class LIB_FIELD;
|
||||
class SCH_FIELD;
|
||||
class EDA_TEXT;
|
||||
|
||||
|
@ -120,6 +122,11 @@ public:
|
|||
void UpdateField( LIB_FIELD* aField )
|
||||
{
|
||||
aField->SetText( m_text );
|
||||
|
||||
// VALUE === component name, so update the parent component if it changes.
|
||||
if( aField->GetId() == VALUE && aField->GetParent() )
|
||||
aField->GetParent()->SetName( m_text );
|
||||
|
||||
updateText( aField );
|
||||
}
|
||||
};
|
||||
|
|
|
@ -508,18 +508,6 @@ void LIB_FIELD::SetText( const wxString& aText )
|
|||
wxString oldValue( m_Text );
|
||||
wxString newValue( aText );
|
||||
|
||||
if( m_id == VALUE && m_Parent != NULL )
|
||||
{
|
||||
LIB_PART* parent = GetParent();
|
||||
|
||||
// Set the parent component and root alias to the new name.
|
||||
if( parent->GetName().CmpNoCase( aText ) != 0 )
|
||||
{
|
||||
ReplaceIllegalFileNameChars( newValue, '_' );
|
||||
parent->SetName( newValue );
|
||||
}
|
||||
}
|
||||
|
||||
if( InEditMode() )
|
||||
{
|
||||
m_Text = oldValue;
|
||||
|
|
Loading…
Reference in New Issue