From 4fac43d696d51bb57d3f1a85f1db71c84473e898 Mon Sep 17 00:00:00 2001 From: Alex Shvartzkop Date: Mon, 15 Jan 2024 09:53:08 +0300 Subject: [PATCH] Fix variable substitutions in library tables. Fixes https://gitlab.com/kicad/code/kicad/-/issues/16601 --- eeschema/dialogs/panel_sym_lib_table.cpp | 7 ++++++- pcbnew/dialogs/panel_fp_lib_table.cpp | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/eeschema/dialogs/panel_sym_lib_table.cpp b/eeschema/dialogs/panel_sym_lib_table.cpp index 49cb403da1..c67112ef5e 100644 --- a/eeschema/dialogs/panel_sym_lib_table.cpp +++ b/eeschema/dialogs/panel_sym_lib_table.cpp @@ -114,12 +114,17 @@ protected: public: void SetValue( int aRow, int aCol, const wxString &aValue ) override { + wxCHECK( aRow < (int) size(), /* void */ ); + LIB_TABLE_GRID::SetValue( aRow, aCol, aValue ); // If setting a filepath, attempt to auto-detect the format if( aCol == COL_URI ) { - SCH_IO_MGR::SCH_FILE_T pluginType = SCH_IO_MGR::GuessPluginTypeFromLibPath( aValue ); + LIB_TABLE_ROW* row = at( (size_t) aRow ); + wxString fullURI = row->GetFullURI( true ); + + SCH_IO_MGR::SCH_FILE_T pluginType = SCH_IO_MGR::GuessPluginTypeFromLibPath( fullURI ); if( pluginType == SCH_IO_MGR::SCH_FILE_UNKNOWN ) pluginType = SCH_IO_MGR::SCH_KICAD; diff --git a/pcbnew/dialogs/panel_fp_lib_table.cpp b/pcbnew/dialogs/panel_fp_lib_table.cpp index cd8a694725..1db4974cac 100644 --- a/pcbnew/dialogs/panel_fp_lib_table.cpp +++ b/pcbnew/dialogs/panel_fp_lib_table.cpp @@ -188,12 +188,17 @@ public: void SetValue( int aRow, int aCol, const wxString &aValue ) override { + wxCHECK( aRow < (int) size(), /* void */ ); + LIB_TABLE_GRID::SetValue( aRow, aCol, aValue ); // If setting a filepath, attempt to auto-detect the format if( aCol == COL_URI ) { - PCB_IO_MGR::PCB_FILE_T pluginType = PCB_IO_MGR::GuessPluginTypeFromLibPath( aValue ); + LIB_TABLE_ROW* row = at( (size_t) aRow ); + wxString fullURI = row->GetFullURI( true ); + + PCB_IO_MGR::PCB_FILE_T pluginType = PCB_IO_MGR::GuessPluginTypeFromLibPath( fullURI ); if( pluginType == PCB_IO_MGR::UNKNOWN ) pluginType = PCB_IO_MGR::KICAD_SEXP;