From 2399759c0388c05c3d1c233a1c53b120e9442531 Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Fri, 6 Jan 2023 10:07:23 -0800 Subject: [PATCH] Allow default sexpr libs to have '.' and no .pretty We default to KICAD_SEXPR format. In this case, if the library doesn't have the .pretty extension, the full directory name including a '.' is the correct nickname Fixes https://gitlab.com/kicad/code/kicad/issues/13388 --- pcbnew/dialogs/panel_fp_lib_table.cpp | 3 +++ pcbnew/footprint_libraries_utils.cpp | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/pcbnew/dialogs/panel_fp_lib_table.cpp b/pcbnew/dialogs/panel_fp_lib_table.cpp index 151418eb11..c4b59d232b 100644 --- a/pcbnew/dialogs/panel_fp_lib_table.cpp +++ b/pcbnew/dialogs/panel_fp_lib_table.cpp @@ -912,6 +912,9 @@ void PANEL_FP_LIB_TABLE::browseLibrariesHandler( wxCommandEvent& event ) wxString nickname = LIB_ID::FixIllegalChars( fn.GetName(), true ); bool doAdd = true; + if( fileType.m_Plugin == IO_MGR::KICAD_SEXP && fn.GetExt() != KiCadFootprintLibPathExtension ) + nickname = LIB_ID::FixIllegalChars( fn.GetFullName(), true ); + if( cur_model()->ContainsNickname( nickname ) ) { if( !applyToAll ) diff --git a/pcbnew/footprint_libraries_utils.cpp b/pcbnew/footprint_libraries_utils.cpp index 9993067c10..692e546431 100644 --- a/pcbnew/footprint_libraries_utils.cpp +++ b/pcbnew/footprint_libraries_utils.cpp @@ -571,8 +571,14 @@ bool PCB_BASE_EDIT_FRAME::AddLibrary( const wxString& aFilename, FP_LIB_TABLE* a if( libName.IsEmpty() ) return false; + IO_MGR::PCB_FILE_T lib_type = IO_MGR::GuessPluginTypeFromLibPath( libPath ); - wxString type = IO_MGR::ShowType( IO_MGR::GuessPluginTypeFromLibPath( libPath ) ); + wxString type = IO_MGR::ShowType( lib_type ); + + // KiCad lib is our default guess. So it might not have the .pretty extension + // In this case, the extension is part of the library name + if( lib_type == IO_MGR::KICAD_SEXP && fn.GetExt() != KiCadFootprintLibPathExtension ) + libName = fn.GetFullName(); // try to use path normalized to an environmental variable or project path wxString normalizedPath = NormalizePath( libPath, &Pgm().GetLocalEnvVariables(), &Prj() );