Update text variables after changes.
Fixes https://gitlab.com/kicad/code/kicad/issues/8697
This commit is contained in:
parent
1db33c7b3a
commit
64f07ea9c6
|
@ -800,6 +800,11 @@ void SCH_EDIT_FRAME::OnModify()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EDA_TEXT* text = dynamic_cast<EDA_TEXT*>( aItem );
|
||||||
|
|
||||||
|
if( text && text->HasTextVars() )
|
||||||
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
} );
|
} );
|
||||||
|
|
||||||
|
|
|
@ -145,14 +145,13 @@ wxString SCH_FIELD::GetShownText( int aDepth ) const
|
||||||
};
|
};
|
||||||
|
|
||||||
PROJECT* project = nullptr;
|
PROJECT* project = nullptr;
|
||||||
bool processTextVars = false;
|
wxString text = EDA_TEXT::GetShownText();
|
||||||
wxString text = EDA_TEXT::GetShownText( &processTextVars );
|
|
||||||
|
|
||||||
if( text == "~" ) // Legacy placeholder for empty string
|
if( text == "~" ) // Legacy placeholder for empty string
|
||||||
{
|
{
|
||||||
text = "";
|
text = "";
|
||||||
}
|
}
|
||||||
else if( processTextVars )
|
else if( HasTextVars() )
|
||||||
{
|
{
|
||||||
if( Schematic() )
|
if( Schematic() )
|
||||||
project = &Schematic()->Prj();
|
project = &Schematic()->Prj();
|
||||||
|
|
|
@ -615,14 +615,13 @@ wxString SCH_TEXT::GetShownText( int aDepth ) const
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
bool processTextVars = false;
|
wxString text = EDA_TEXT::GetShownText();
|
||||||
wxString text = EDA_TEXT::GetShownText( &processTextVars );
|
|
||||||
|
|
||||||
if( text == "~" ) // Legacy placeholder for empty string
|
if( text == "~" ) // Legacy placeholder for empty string
|
||||||
{
|
{
|
||||||
text = "";
|
text = "";
|
||||||
}
|
}
|
||||||
else if( processTextVars )
|
else if( HasTextVars() )
|
||||||
{
|
{
|
||||||
wxCHECK_MSG( Schematic(), wxEmptyString, "No parent SCHEMATIC set for SCH_TEXT!" );
|
wxCHECK_MSG( Schematic(), wxEmptyString, "No parent SCHEMATIC set for SCH_TEXT!" );
|
||||||
|
|
||||||
|
|
|
@ -140,23 +140,16 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual wxString GetShownText( int aDepth = 0 ) const { return m_shown_text; }
|
virtual wxString GetShownText( int aDepth = 0 ) const { return m_shown_text; }
|
||||||
|
|
||||||
/**
|
|
||||||
* A version of GetShownText() which also indicates whether or not the text needs
|
|
||||||
* to be processed for text variables.
|
|
||||||
*
|
|
||||||
* @param processTextVars [out]
|
|
||||||
*/
|
|
||||||
wxString GetShownText( bool* processTextVars ) const
|
|
||||||
{
|
|
||||||
*processTextVars = m_shown_text_has_text_var_refs;
|
|
||||||
return m_shown_text;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a shortened version (max 15 characters) of the shown text
|
* Returns a shortened version (max 15 characters) of the shown text
|
||||||
*/
|
*/
|
||||||
wxString ShortenedShownText() const;
|
wxString ShortenedShownText() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicates the ShownText has text var references which need to be processed.
|
||||||
|
*/
|
||||||
|
bool HasTextVars() const { return m_shown_text_has_text_var_refs; }
|
||||||
|
|
||||||
virtual void SetText( const wxString& aText );
|
virtual void SetText( const wxString& aText );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -429,10 +429,9 @@ wxString FP_TEXT::GetShownText( int aDepth ) const
|
||||||
return board->ResolveTextVar( token, aDepth + 1 );
|
return board->ResolveTextVar( token, aDepth + 1 );
|
||||||
};
|
};
|
||||||
|
|
||||||
bool processTextVars = false;
|
wxString text = EDA_TEXT::GetShownText();
|
||||||
wxString text = EDA_TEXT::GetShownText( &processTextVars );
|
|
||||||
|
|
||||||
if( processTextVars )
|
if( HasTextVars() )
|
||||||
{
|
{
|
||||||
PROJECT* project = nullptr;
|
PROJECT* project = nullptr;
|
||||||
|
|
||||||
|
|
|
@ -92,10 +92,9 @@ wxString PCB_TEXT::GetShownText( int aDepth ) const
|
||||||
return board->ResolveTextVar( token, aDepth + 1 );
|
return board->ResolveTextVar( token, aDepth + 1 );
|
||||||
};
|
};
|
||||||
|
|
||||||
bool processTextVars = false;
|
wxString text = EDA_TEXT::GetShownText();
|
||||||
wxString text = EDA_TEXT::GetShownText( &processTextVars );
|
|
||||||
|
|
||||||
if( board && processTextVars && aDepth < 10 )
|
if( board && HasTextVars() && aDepth < 10 )
|
||||||
text = ExpandTextVars( text, &pcbTextResolver, &boardTextResolver, board->GetProject() );
|
text = ExpandTextVars( text, &pcbTextResolver, &boardTextResolver, board->GetProject() );
|
||||||
|
|
||||||
return text;
|
return text;
|
||||||
|
|
Loading…
Reference in New Issue