diff --git a/common/advanced_config.cpp b/common/advanced_config.cpp index 13fa92b694..1ff3702024 100644 --- a/common/advanced_config.cpp +++ b/common/advanced_config.cpp @@ -113,6 +113,7 @@ static const wxChar EnableCacheFriendlyFracture[] = wxT( "EnableCacheFriendlyFra static const wxChar EnableAPILogging[] = wxT( "EnableAPILogging" ); static const wxChar MaxFileSystemWatchers[] = wxT( "MaxFileSystemWatchers" ); static const wxChar MinorSchematicGraphSize[] = wxT( "MinorSchematicGraphSize" ); +static const wxChar ResolveTextRecursionDepth[] = wxT( "ResolveTextRecursionDepth" ); } // namespace KEYS @@ -271,6 +272,8 @@ ADVANCED_CFG::ADVANCED_CFG() m_MinorSchematicGraphSize = 10000; + m_ResolveTextRecursionDepth = 2; + loadFromConfigFile(); } @@ -501,6 +504,10 @@ void ADVANCED_CFG::loadSettings( wxConfigBase& aCfg ) &m_MinorSchematicGraphSize, m_MinorSchematicGraphSize, 0, 2147483647 ) ); + configParams.push_back( new PARAM_CFG_INT( true, AC_KEYS::ResolveTextRecursionDepth, + &m_ResolveTextRecursionDepth, + m_ResolveTextRecursionDepth, 0, 10 ) ); + // Special case for trace mask setting...we just grab them and set them immediately // Because we even use wxLogTrace inside of advanced config wxString traceMasks; diff --git a/eeschema/sch_field.cpp b/eeschema/sch_field.cpp index 2f35a76e65..5770d3aa74 100644 --- a/eeschema/sch_field.cpp +++ b/eeschema/sch_field.cpp @@ -32,6 +32,8 @@ #include #include + +#include #include #include // for ExpandTextVars #include @@ -264,9 +266,14 @@ wxString SCH_FIELD::GetShownText( const SCH_SHEET_PATH* aPath, bool aAllowExtraT if( text == wxS( "~" ) ) // Legacy placeholder for empty string text = wxS( "" ); + // The iteration here it to allow for nested variables in the + // text strings (e.g. ${${VAR}}). Although the symbols and sheets + // and labels recurse, text that is none of those types such as text + // boxes and labels do not. This only loops if there is still a + // variable to resolve. for( int ii = 0; ii < 10 && text.Contains( wxT( "${" ) ); ++ii ) { - if( aDepth < 10 ) + if( aDepth < ADVANCED_CFG::GetCfg().m_ResolveTextRecursionDepth ) { if( m_parent && m_parent->Type() == LIB_SYMBOL_T ) text = ExpandTextVars( text, &libSymbolResolver ); diff --git a/eeschema/sch_label.cpp b/eeschema/sch_label.cpp index 8fa5e4106a..84321dff46 100644 --- a/eeschema/sch_label.cpp +++ b/eeschema/sch_label.cpp @@ -23,6 +23,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ +#include #include #include #include @@ -909,7 +910,7 @@ wxString SCH_LABEL_BASE::GetShownText( const SCH_SHEET_PATH* aPath, bool aAllowE } else if( HasTextVars() ) { - if( aDepth < 10 ) + if( aDepth < ADVANCED_CFG::GetCfg().m_ResolveTextRecursionDepth ) text = ExpandTextVars( text, &textResolver ); } diff --git a/eeschema/sch_text.cpp b/eeschema/sch_text.cpp index 529c2094d7..5185605bbf 100644 --- a/eeschema/sch_text.cpp +++ b/eeschema/sch_text.cpp @@ -23,6 +23,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ +#include #include #include #include @@ -432,7 +433,7 @@ wxString SCH_TEXT::GetShownText( const SCH_SHEET_PATH* aPath, bool aAllowExtraTe } else if( HasTextVars() ) { - if( aDepth < 10 ) + if( aDepth < ADVANCED_CFG::GetCfg().m_ResolveTextRecursionDepth ) text = ExpandTextVars( text, &textResolver ); } diff --git a/eeschema/sch_textbox.cpp b/eeschema/sch_textbox.cpp index afcad2b4ed..e708d6853f 100644 --- a/eeschema/sch_textbox.cpp +++ b/eeschema/sch_textbox.cpp @@ -21,6 +21,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ +#include #include #include #include @@ -364,7 +365,7 @@ wxString SCH_TEXTBOX::GetShownText( const SCH_SHEET_PATH* aPath, bool aAllowExtr if( HasTextVars() ) { - if( aDepth < 10 ) + if( aDepth < ADVANCED_CFG::GetCfg().m_ResolveTextRecursionDepth ) text = ExpandTextVars( text, &textResolver ); } diff --git a/include/advanced_config.h b/include/advanced_config.h index a7360e13e9..b655e7c701 100644 --- a/include/advanced_config.h +++ b/include/advanced_config.h @@ -599,6 +599,15 @@ public: */ int m_MinorSchematicGraphSize; + /** + * The number of recursions to resolve text variables. + * + * Setting name: "ResolveTextRecursionDepth" + * Valid values: 0 to 10 + * Default value: 2 + */ + int m_ResolveTextRecursionDepth; + ///@} private: diff --git a/pcbnew/pcb_text.cpp b/pcbnew/pcb_text.cpp index 803e97375c..be6c205611 100644 --- a/pcbnew/pcb_text.cpp +++ b/pcbnew/pcb_text.cpp @@ -25,6 +25,7 @@ #include +#include #include #include #include @@ -209,7 +210,7 @@ wxString PCB_TEXT::GetShownText( bool aAllowExtraText, int aDepth ) const if( HasTextVars() ) { - if( aDepth < 10 ) + if( aDepth < ADVANCED_CFG::GetCfg().m_ResolveTextRecursionDepth ) text = ExpandTextVars( text, &resolver ); }