Fix variable substitutions in library tables.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/16601
This commit is contained in:
Alex Shvartzkop 2024-01-15 09:53:08 +03:00
parent b7460f29b4
commit 4fac43d696
2 changed files with 12 additions and 2 deletions

View File

@ -114,12 +114,17 @@ protected:
public: public:
void SetValue( int aRow, int aCol, const wxString &aValue ) override void SetValue( int aRow, int aCol, const wxString &aValue ) override
{ {
wxCHECK( aRow < (int) size(), /* void */ );
LIB_TABLE_GRID::SetValue( aRow, aCol, aValue ); LIB_TABLE_GRID::SetValue( aRow, aCol, aValue );
// If setting a filepath, attempt to auto-detect the format // If setting a filepath, attempt to auto-detect the format
if( aCol == COL_URI ) 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 ) if( pluginType == SCH_IO_MGR::SCH_FILE_UNKNOWN )
pluginType = SCH_IO_MGR::SCH_KICAD; pluginType = SCH_IO_MGR::SCH_KICAD;

View File

@ -188,12 +188,17 @@ public:
void SetValue( int aRow, int aCol, const wxString &aValue ) override void SetValue( int aRow, int aCol, const wxString &aValue ) override
{ {
wxCHECK( aRow < (int) size(), /* void */ );
LIB_TABLE_GRID::SetValue( aRow, aCol, aValue ); LIB_TABLE_GRID::SetValue( aRow, aCol, aValue );
// If setting a filepath, attempt to auto-detect the format // If setting a filepath, attempt to auto-detect the format
if( aCol == COL_URI ) 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 ) if( pluginType == PCB_IO_MGR::UNKNOWN )
pluginType = PCB_IO_MGR::KICAD_SEXP; pluginType = PCB_IO_MGR::KICAD_SEXP;