From e03bca35632cb6f9d742ffb48ff775b6e641543a Mon Sep 17 00:00:00 2001 From: Roberto Fernandez Bautista Date: Fri, 26 Feb 2021 18:40:25 +0000 Subject: [PATCH] Non-KiCad Project Importers: Fix broken project import Fixes bug introduced in b4741c97b669e8b8e481e71ec391f03e81ceb43b --- kicad/import_project.cpp | 44 ++++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/kicad/import_project.cpp b/kicad/import_project.cpp index c9fb16e8f3..22b3e0746b 100644 --- a/kicad/import_project.cpp +++ b/kicad/import_project.cpp @@ -130,35 +130,39 @@ void KICAD_MANAGER_FRAME::ImportNonKiCadProject( wxString aWindowTitle, wxString wxFileName schCopy( pro ); schCopy.SetExt( aSchFileExtension ); - if( sch.Exists() && !schCopy.SameAs( sch ) - && wxCopyFile( sch.GetFullPath(), schCopy.GetFullPath(), true ) ) + if( sch.Exists() && !schCopy.SameAs( sch ) ) { - ///< @todo Should we remove the newly created folder? - msg.Printf( _( "Cannot copy file '%s'\n" - "to '%s'\n" - "The project cannot be imported." ), - sch.GetFullPath(), schCopy.GetFullPath() ); + if( !wxCopyFile( sch.GetFullPath(), schCopy.GetFullPath(), true ) ) + { + ///< @todo Should we remove the newly created folder? + msg.Printf( _( "Cannot copy file '%s'\n" + "to '%s'\n" + "The project cannot be imported." ), + sch.GetFullPath(), schCopy.GetFullPath() ); - wxMessageDialog schCopyErrorDlg( this, msg, _( "Error" ), wxOK_DEFAULT | wxICON_ERROR ); - schCopyErrorDlg.ShowModal(); - return; + wxMessageDialog schCopyErrorDlg( this, msg, _( "Error" ), wxOK_DEFAULT | wxICON_ERROR ); + schCopyErrorDlg.ShowModal(); + return; + } } wxFileName pcbCopy( pro ); pcbCopy.SetExt( aPcbFileExtension ); - if( pcb.Exists() && !pcbCopy.SameAs( pcb ) - && wxCopyFile( pcb.GetFullPath(), pcbCopy.GetFullPath(), true ) ) + if( pcb.Exists() && !pcbCopy.SameAs( pcb ) ) { - ///< @todo Should we remove copied schematic file and the newly created folder? - msg.Printf( _( "Cannot copy file '%s'\n" - "to '%s'\n" - "The project cannot be imported." ), - sch.GetFullPath(), schCopy.GetFullPath() ); + if( !wxCopyFile( pcb.GetFullPath(), pcbCopy.GetFullPath(), true ) ) + { + ///< @todo Should we remove copied schematic file and the newly created folder? + msg.Printf( _( "Cannot copy file '%s'\n" + "to '%s'\n" + "The project cannot be imported." ), + pcb.GetFullPath(), pcbCopy.GetFullPath() ); - wxMessageDialog brdCopyErrorDlg( this, msg, _( "Error" ), wxOK_DEFAULT | wxICON_ERROR ); - brdCopyErrorDlg.ShowModal(); - return; + wxMessageDialog brdCopyErrorDlg( this, msg, _( "Error" ), wxOK_DEFAULT | wxICON_ERROR ); + brdCopyErrorDlg.ShowModal(); + return; + } } // Close the project and make the new one