Fix 3D model resolution for older boards
Older boards use older 3d model environmental variables. We need to support both older environmental variables (if the user has them) as well as updated environmental variables (if the user only has a single 3d model path) This updated the environmental resolver to look first in the named location and then substitute the new location if the old location is not defined in the environment Fixes https://gitlab.com/kicad/code/kicad/issues/10674
This commit is contained in:
parent
ed0d57ddf6
commit
d8ac53d7b4
|
@ -27,6 +27,7 @@
|
|||
#include <kiplatform/app.h>
|
||||
#include <project.h>
|
||||
#include <common.h>
|
||||
#include <env_vars.h>
|
||||
#include <reporter.h>
|
||||
#include <macros.h>
|
||||
#include <mutex>
|
||||
|
@ -196,6 +197,27 @@ wxString KIwxExpandEnvVars( const wxString& str, const PROJECT* aProject )
|
|||
strResult += tmp;
|
||||
expanded = true;
|
||||
}
|
||||
// Replace unmatched older variables with current 3d model locations
|
||||
// If the user has the older model location defined, that will be matched
|
||||
// first above. But if they do not, this will ensure that their board still
|
||||
// displays correctly
|
||||
else if( strVarName.Contains( "KISYS3DMOD") || strVarName.Matches( "KICAD*_3DMODEL_DIR" ) )
|
||||
{
|
||||
for( auto& var : ENV_VAR::GetPredefinedEnvVars() )
|
||||
{
|
||||
if( var.Matches( "KICAD*_3DMODEL_DIR" ) )
|
||||
{
|
||||
const auto value = ENV_VAR::GetEnvVar<wxString>( var );
|
||||
|
||||
if( !value )
|
||||
continue;
|
||||
|
||||
strResult += *value;
|
||||
expanded = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// variable doesn't exist => don't change anything
|
||||
|
|
Loading…
Reference in New Issue