DIALOG_SPICE_MODEL: expand environment vars in spice library path.

This commit is contained in:
jean-pierre charras 2021-07-09 18:22:42 +02:00
parent 6c3ba1c20b
commit 928c4e8ed7
1 changed files with 7 additions and 7 deletions

View File

@ -29,6 +29,7 @@
#include <sim/spice_value.h> #include <sim/spice_value.h>
#include <confirm.h> #include <confirm.h>
#include <project.h> #include <project.h>
#include <common.h>
#include <wx/textfile.h> #include <wx/textfile.h>
#include <wx/tokenzr.h> #include <wx/tokenzr.h>
@ -836,19 +837,18 @@ bool DIALOG_SPICE_MODEL::generatePowerSource( wxString& aTarget ) const
void DIALOG_SPICE_MODEL::loadLibrary( const wxString& aFilePath ) void DIALOG_SPICE_MODEL::loadLibrary( const wxString& aFilePath )
{ {
//First, expand env vars, if any
wxString libname = ExpandEnvVarSubstitutions( aFilePath, &Prj() );
// Add make path absolute, especially if relative to the project path
libname = Prj().AbsolutePath( libname );
wxString curModel = m_modelName->GetValue(); wxString curModel = m_modelName->GetValue();
m_models.clear(); m_models.clear();
wxFileName filePath( aFilePath ); wxFileName filePath( libname );
bool in_subckt = false; // flag indicating that the parser is inside a .subckt section bool in_subckt = false; // flag indicating that the parser is inside a .subckt section
// Look for the file in the project path
if( !filePath.Exists() ) if( !filePath.Exists() )
{
filePath.SetPath( Prj().GetProjectPath() + filePath.GetPath() );
if( !filePath.Exists() )
return; return;
}
// Display the library contents // Display the library contents
wxWindowUpdateLocker updateLock( this ); wxWindowUpdateLocker updateLock( this );