Update text variables after changes.

Fixes https://gitlab.com/kicad/code/kicad/issues/8697
This commit is contained in:
Jeff Young 2021-06-29 13:54:40 +01:00
parent 1db33c7b3a
commit 64f07ea9c6
6 changed files with 18 additions and 24 deletions

View File

@ -800,6 +800,11 @@ void SCH_EDIT_FRAME::OnModify()
return true;
}
EDA_TEXT* text = dynamic_cast<EDA_TEXT*>( aItem );
if( text && text->HasTextVars() )
return true;
return false;
} );

View File

@ -145,14 +145,13 @@ wxString SCH_FIELD::GetShownText( int aDepth ) const
};
PROJECT* project = nullptr;
bool processTextVars = false;
wxString text = EDA_TEXT::GetShownText( &processTextVars );
wxString text = EDA_TEXT::GetShownText();
if( text == "~" ) // Legacy placeholder for empty string
{
text = "";
}
else if( processTextVars )
else if( HasTextVars() )
{
if( Schematic() )
project = &Schematic()->Prj();

View File

@ -615,14 +615,13 @@ wxString SCH_TEXT::GetShownText( int aDepth ) const
return false;
};
bool processTextVars = false;
wxString text = EDA_TEXT::GetShownText( &processTextVars );
wxString text = EDA_TEXT::GetShownText();
if( text == "~" ) // Legacy placeholder for empty string
{
text = "";
}
else if( processTextVars )
else if( HasTextVars() )
{
wxCHECK_MSG( Schematic(), wxEmptyString, "No parent SCHEMATIC set for SCH_TEXT!" );

View File

@ -140,23 +140,16 @@ public:
*/
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
*/
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 );
/**

View File

@ -429,10 +429,9 @@ wxString FP_TEXT::GetShownText( int aDepth ) const
return board->ResolveTextVar( token, aDepth + 1 );
};
bool processTextVars = false;
wxString text = EDA_TEXT::GetShownText( &processTextVars );
wxString text = EDA_TEXT::GetShownText();
if( processTextVars )
if( HasTextVars() )
{
PROJECT* project = nullptr;

View File

@ -92,10 +92,9 @@ wxString PCB_TEXT::GetShownText( int aDepth ) const
return board->ResolveTextVar( token, aDepth + 1 );
};
bool processTextVars = false;
wxString text = EDA_TEXT::GetShownText( &processTextVars );
wxString text = EDA_TEXT::GetShownText();
if( board && processTextVars && aDepth < 10 )
if( board && HasTextVars() && aDepth < 10 )
text = ExpandTextVars( text, &pcbTextResolver, &boardTextResolver, board->GetProject() );
return text;