diff --git a/eeschema/sch_plugins/kicad/sch_sexpr_parser.cpp b/eeschema/sch_plugins/kicad/sch_sexpr_parser.cpp index 57f17c2bea..84cbc92aee 100644 --- a/eeschema/sch_plugins/kicad/sch_sexpr_parser.cpp +++ b/eeschema/sch_plugins/kicad/sch_sexpr_parser.cpp @@ -61,6 +61,7 @@ #include #include + using namespace TSCHEMATIC_T; @@ -1948,7 +1949,6 @@ SCH_FIELD* SCH_SEXPR_PARSER::parseSchField( SCH_ITEM* aParent ) std::unique_ptr field = std::make_unique( wxDefaultPosition, -1, aParent, name ); - field->SetText( value ); field->SetVisible( true ); @@ -3853,6 +3853,10 @@ SCH_TEXT* SCH_SEXPR_PARSER::parseSchText() || field->GetInternalName() == wxT( "Intersheetrefs" ) ) ) // Current name { SCH_GLOBALLABEL* label = static_cast( text.get() ); + // Ensure the Id of this special and first field is 0, needed by + // SCH_FIELD::IsHypertext() test + field->SetId( 0 ); + label->GetFields()[0] = *field; } else diff --git a/eeschema/tools/sch_edit_tool.cpp b/eeschema/tools/sch_edit_tool.cpp index f884d6b7dc..7035d4ff8f 100644 --- a/eeschema/tools/sch_edit_tool.cpp +++ b/eeschema/tools/sch_edit_tool.cpp @@ -2165,8 +2165,23 @@ int SCH_EDIT_TOOL::ChangeTextType( const TOOL_EVENT& aEvent ) SCH_LABEL_BASE* new_label = dynamic_cast( newtext ); if( label && new_label ) + { new_label->AddFields( label->GetFields() ); + // A SCH_GLOBALLABEL has a specific field, that has no meaning for + // other labels, and expected to be the first field in list. + // It is the first field in list for this kind of label + // So remove field named "Intersheetrefs" if exists for other labels + int min_idx = new_label->Type() == SCH_GLOBAL_LABEL_T ? 1 : 0; + std::vector& fields = new_label->GetFields(); + + for( int ii = fields.size()-1; ii >= min_idx; ii-- ) + { + if( fields[ii].GetCanonicalName() == wxT( "Intersheetrefs" ) ) + fields.erase( fields.begin() + ii ); + } + } + if( selected ) m_toolMgr->RunAction( EE_ACTIONS::removeItemFromSel, true, item );