Simplify KICAD6_TEMPLATE_DIR default
The search_stack method is bugland Fix https://gitlab.com/kicad/code/kicad/-/issues/10119
This commit is contained in:
parent
e35c3f2b99
commit
ad251b7b8c
|
@ -239,6 +239,16 @@ wxString PATHS::GetStockScriptingPath()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
wxString PATHS::GetStockTemplatesPath()
|
||||||
|
{
|
||||||
|
wxString path;
|
||||||
|
|
||||||
|
path = GetStockDataPath() + wxT( "/template" );
|
||||||
|
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
wxString PATHS::GetStockPluginsPath()
|
wxString PATHS::GetStockPluginsPath()
|
||||||
{
|
{
|
||||||
wxFileName fn;
|
wxFileName fn;
|
||||||
|
|
|
@ -514,44 +514,7 @@ void COMMON_SETTINGS::InitializeEnvironment()
|
||||||
path.AppendDir( wxT( "3dmodels" ) );
|
path.AppendDir( wxT( "3dmodels" ) );
|
||||||
addVar( wxT( "KICAD6_3DMODEL_DIR" ), path.GetFullPath() );
|
addVar( wxT( "KICAD6_3DMODEL_DIR" ), path.GetFullPath() );
|
||||||
|
|
||||||
// We don't have just one default template path, so use this logic that originally was in
|
addVar( wxT( "KICAD6_TEMPLATE_DIR" ), PATHS::GetStockTemplatesPath() );
|
||||||
// PGM_BASE::InitPgm to determine the best default template path
|
|
||||||
{
|
|
||||||
// Attempt to find the best default template path.
|
|
||||||
SEARCH_STACK bases;
|
|
||||||
SEARCH_STACK templatePaths;
|
|
||||||
|
|
||||||
SystemDirsAppend( &bases );
|
|
||||||
|
|
||||||
for( unsigned i = 0; i < bases.GetCount(); ++i )
|
|
||||||
{
|
|
||||||
wxFileName fn( bases[i], wxEmptyString );
|
|
||||||
|
|
||||||
// Add KiCad template file path to search path list.
|
|
||||||
fn.AppendDir( "template" );
|
|
||||||
|
|
||||||
// Only add path if exists and can be read by the user.
|
|
||||||
if( fn.DirExists() && fn.IsDirReadable() )
|
|
||||||
{
|
|
||||||
wxLogTrace( tracePathsAndFiles, "Checking template path '%s' exists",
|
|
||||||
fn.GetPath() );
|
|
||||||
templatePaths.AddPaths( fn.GetPath() );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if( templatePaths.IsEmpty() )
|
|
||||||
{
|
|
||||||
path = basePath;
|
|
||||||
path.AppendDir( "template" );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Take the first one. There may be more but this will likely be the best option.
|
|
||||||
path.AssignDir( templatePaths[0] );
|
|
||||||
}
|
|
||||||
|
|
||||||
addVar( wxT( "KICAD6_TEMPLATE_DIR" ), path.GetFullPath() );
|
|
||||||
}
|
|
||||||
|
|
||||||
addVar( wxT( "KICAD_USER_TEMPLATE_DIR" ), PATHS::GetUserTemplatesPath() );
|
addVar( wxT( "KICAD_USER_TEMPLATE_DIR" ), PATHS::GetUserTemplatesPath() );
|
||||||
|
|
||||||
|
|
|
@ -121,6 +121,11 @@ public:
|
||||||
*/
|
*/
|
||||||
static wxString GetStockDemosPath();
|
static wxString GetStockDemosPath();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the stock (install) templates path
|
||||||
|
*/
|
||||||
|
static wxString GetStockTemplatesPath();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the stock (install) 3d viewer plugins path
|
* Gets the stock (install) 3d viewer plugins path
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue