diff --git a/eeschema/sch_edit_frame.cpp b/eeschema/sch_edit_frame.cpp index ce09c1bc43..4f3a702cad 100644 --- a/eeschema/sch_edit_frame.cpp +++ b/eeschema/sch_edit_frame.cpp @@ -800,6 +800,11 @@ void SCH_EDIT_FRAME::OnModify() return true; } + EDA_TEXT* text = dynamic_cast( aItem ); + + if( text && text->HasTextVars() ) + return true; + return false; } ); diff --git a/eeschema/sch_field.cpp b/eeschema/sch_field.cpp index 115a37d1ec..bb08f64532 100644 --- a/eeschema/sch_field.cpp +++ b/eeschema/sch_field.cpp @@ -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(); diff --git a/eeschema/sch_text.cpp b/eeschema/sch_text.cpp index ed8c6abb48..fd5aa6ac48 100644 --- a/eeschema/sch_text.cpp +++ b/eeschema/sch_text.cpp @@ -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!" ); diff --git a/include/eda_text.h b/include/eda_text.h index c5170dc61e..cb05d2b788 100644 --- a/include/eda_text.h +++ b/include/eda_text.h @@ -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 ); /** diff --git a/pcbnew/fp_text.cpp b/pcbnew/fp_text.cpp index b281cae853..84e8f5c1ba 100644 --- a/pcbnew/fp_text.cpp +++ b/pcbnew/fp_text.cpp @@ -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; diff --git a/pcbnew/pcb_text.cpp b/pcbnew/pcb_text.cpp index 9df862b085..1af9d0f91c 100644 --- a/pcbnew/pcb_text.cpp +++ b/pcbnew/pcb_text.cpp @@ -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;