From c79dd09464d172d91aeb9902a608397c8de320b2 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Thu, 16 Jun 2022 13:04:27 +0200 Subject: [PATCH] PANEL_SYM_LIB_TABLE: fix a bug in filenames from wxFileDialog dialog. We want the full path, so use GetPaths. GetFilenames sometimes return the full path in wxWidgets 3.1.7, not always the filename Fixes #11821 https://gitlab.com/kicad/code/kicad/issues/11821 --- eeschema/dialogs/panel_sym_lib_table.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/eeschema/dialogs/panel_sym_lib_table.cpp b/eeschema/dialogs/panel_sym_lib_table.cpp index a82cafdd5d..0f69ee0929 100644 --- a/eeschema/dialogs/panel_sym_lib_table.cpp +++ b/eeschema/dialogs/panel_sym_lib_table.cpp @@ -3,7 +3,7 @@ * * Copyright (C) 2017 Wayne Stambaugh * Copyright (C) 2021 CERN - * Copyright (C) 2017-2021 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2017-2022 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the @@ -505,12 +505,11 @@ void PANEL_SYM_LIB_TABLE::browseLibrariesHandler( wxCommandEvent& event ) wxString detailedMsg = _( "One of the nicknames will need to be changed after " "adding this library." ); - wxArrayString files; - dlg.GetFilenames( files ); + wxArrayString filePathsList; + dlg.GetPaths( filePathsList ); - for( const wxString& file : files ) + for( const wxString& filePath : filePathsList ) { - wxString filePath = dlg.GetDirectory() + wxFileName::GetPathSeparator() + file; wxFileName fn( filePath ); wxString nickname = LIB_ID::FixIllegalChars( fn.GetName(), true ); bool doAdd = true; @@ -556,7 +555,7 @@ void PANEL_SYM_LIB_TABLE::browseLibrariesHandler( wxCommandEvent& event ) } } - if( !files.IsEmpty() ) + if( !filePathsList.IsEmpty() ) { m_cur_grid->MakeCellVisible( m_cur_grid->GetNumberRows() - 1, 0 ); m_cur_grid->SetGridCursor( m_cur_grid->GetNumberRows() - 1, 1 );