eeschema: inconsistency in path resolving of spice models
Description
I found a inconsistency in how file paths for spice models are handled. The pspice netlist exporter applies the function ResolveFile on the paths to spice models (see function "NETLIST_EXPORTER_PSPICE::Format"). The spice model dialog is not doing it and therefor is not loading the content of the models even if the path is correct. The following patch solves this problem partly. I don't know to get the a pointer to the current "PROJECT" in the dialog:
diff --git a/eeschema/dialogs/dialog_spice_model.cpp b/eeschema/dialogs/dialog_spice_model.cpp
index 451ae514c..ce184bddd 100644
--- a/eeschema/dialogs/dialog_spice_model.cpp
+++ b/eeschema/dialogs/dialog_spice_model.cpp
@@ -30,6 +30,8 @@
#include <confirm.h>
#include <project.h>
+#include <env_paths.h>
+
#include <wx/tokenzr.h>
#include <wx/wupdlock.h>
@@ -367,7 +369,8 @@ bool DIALOG_SPICE_MODEL::TransferDataToWindow()
{
const wxString& libFile = m_modelLibrary->GetValue();
m_fieldsTmp[SF_LIB_FILE] = libFile;
- loadLibrary( libFile );
+ const wxString resolvedFile = ResolveFile(libFile, &Pgm().GetLocalEnvVariables(), nullptr);
+ loadLibrary( resolvedFile );
}
break;
My personal opinion: I would prefer a path resolution, which invokes the FILENAME_RESOLVER instead the ResolveFile function. This would prevent file name conflicts which is currently possible if two file with the same name is located in different configured paths. Furthermore, i think that for users is would be more clear what KiCad is doing, since the names of the used environment variables for resolving the paths would also be accessible for from the GUI. Unfortunately, this probably breaks backward compatibility.
Steps to reproduce
none
KiCad Version
Application: KiCad
Version: (5.99.0-1336-g8f0449cba-dirty), release build
Libraries:
wxWidgets 3.0.4
libcurl/7.69.1 OpenSSL/1.1.1e zlib/1.2.11 libidn2/2.3.0 libpsl/0.21.0 (+libidn2/2.2.0) libssh2/1.9.0 nghttp2/1.39.2
Platform: Linux 5.5.13-arch1-1 x86_64, 64 bit, Little endian, wxGTK
Build Info:
Build date: Apr 18 2020 12:36:30
wxWidgets: 3.0.4 (wchar_t,wx containers,compatible with 2.8) GTK+ 3.24
Boost: 1.72.0
OpenCASCADE Technology: 7.4.0
Curl: 7.69.1
Compiler: GCC 9.3.0 with C++ ABI 1013
Build settings:
KICAD_SCRIPTING=ON
KICAD_SCRIPTING_MODULES=ON
KICAD_SCRIPTING_PYTHON3=OFF
KICAD_SCRIPTING_WXPYTHON=ON
KICAD_SCRIPTING_WXPYTHON_PHOENIX=OFF
KICAD_SCRIPTING_ACTION_MENU=ON
BUILD_GITHUB_PLUGIN=ON
KICAD_USE_OCE=OFF
KICAD_USE_OCC=ON
KICAD_SPICE=ON