Attempt to use envVars when adding new libraries.
Fixes: lp:1785441 * https://bugs.launchpad.net/kicad/+bug/1785441
This commit is contained in:
parent
4854d92c73
commit
3e61a32fbe
|
@ -27,7 +27,8 @@
|
|||
#include <class_library.h>
|
||||
#include <lib_edit_frame.h>
|
||||
#include <confirm.h>
|
||||
|
||||
#include <env_paths.h>
|
||||
#include <pgm_base.h>
|
||||
#include <kiway.h>
|
||||
#include <profile.h>
|
||||
#include <symbol_lib_table.h>
|
||||
|
@ -622,7 +623,13 @@ bool LIB_MANAGER::addLibrary( const wxString& aFilePath, bool aCreate, SYMBOL_LI
|
|||
wxString libName = getLibraryName( aFilePath );
|
||||
wxCHECK( !LibraryExists( libName ), false ); // either create or add an existing one
|
||||
|
||||
SYMBOL_LIB_TABLE_ROW* libRow = new SYMBOL_LIB_TABLE_ROW( libName, aFilePath,
|
||||
// try to use path normalized to an environmental variable or project path
|
||||
wxString relPath = NormalizePath( aFilePath, &Pgm().GetLocalEnvVariables(), &m_frame.Prj() );
|
||||
|
||||
if( relPath.IsEmpty() )
|
||||
relPath = aFilePath;
|
||||
|
||||
SYMBOL_LIB_TABLE_ROW* libRow = new SYMBOL_LIB_TABLE_ROW( libName, relPath,
|
||||
SCH_IO_MGR::ShowType( SCH_IO_MGR::SCH_LEGACY ) );
|
||||
aTable->InsertRow( libRow );
|
||||
|
||||
|
|
|
@ -53,6 +53,7 @@
|
|||
#include <wildcards_and_files_ext.h>
|
||||
#include <kicad_plugin.h>
|
||||
#include <legacy_plugin.h>
|
||||
#include <env_paths.h>
|
||||
|
||||
|
||||
// unique, "file local" translations:
|
||||
|
@ -500,15 +501,21 @@ wxString PCB_BASE_EDIT_FRAME::CreateNewLibrary(const wxString& aLibName )
|
|||
|
||||
pi->FootprintLibCreate( libPath );
|
||||
|
||||
// try to use path normalized to an environmental variable or project path
|
||||
wxString path = NormalizePath( libPath, &Pgm().GetLocalEnvVariables(), &Prj() );
|
||||
|
||||
if( path.IsEmpty() )
|
||||
path = libPath;
|
||||
|
||||
if( saveInGlobalTable )
|
||||
{
|
||||
auto row = new FP_LIB_TABLE_ROW( fn.GetName(), libPath, wxT( "KiCad" ), wxEmptyString );
|
||||
auto row = new FP_LIB_TABLE_ROW( fn.GetName(), path, wxT( "KiCad" ), wxEmptyString );
|
||||
GFootprintTable.InsertRow( row );
|
||||
GFootprintTable.Save( FP_LIB_TABLE::GetGlobalTableFileName() );
|
||||
}
|
||||
else if( saveInProjectTable )
|
||||
{
|
||||
auto row = new FP_LIB_TABLE_ROW( fn.GetName(), libPath, wxT( "KiCad" ), wxEmptyString );
|
||||
auto row = new FP_LIB_TABLE_ROW( fn.GetName(), path, wxT( "KiCad" ), wxEmptyString );
|
||||
Prj().PcbFootprintLibs()->InsertRow( row );
|
||||
Prj().PcbFootprintLibs()->Save( Prj().FootprintLibTblName() );
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue