Attempt to fix Coverity issue 316502.
This changes the third party project importer to fail if either the schematic or board files cannot be copied to the project folder.
This commit is contained in:
parent
87ea540953
commit
b4741c97b6
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
*
|
*
|
||||||
* Copyright (C) 2017-2020 KiCad Developers, see AUTHORS.txt for contributors.
|
* Copyright (C) 2017-2021 KiCad Developers, see AUTHORS.txt for contributors.
|
||||||
*
|
*
|
||||||
* @author Russell Oliver <roliver8143@gmail.com>
|
* @author Russell Oliver <roliver8143@gmail.com>
|
||||||
*
|
*
|
||||||
|
@ -111,7 +111,7 @@ void KICAD_MANAGER_FRAME::ImportNonKiCadProject( wxString aWindowTitle, wxString
|
||||||
if( !wxMkdir( pro.GetPath() ) )
|
if( !wxMkdir( pro.GetPath() ) )
|
||||||
{
|
{
|
||||||
msg = _( "Error creating new directory. Please try a different path. The "
|
msg = _( "Error creating new directory. Please try a different path. The "
|
||||||
"project was not imported." );
|
"project cannot be imported." );
|
||||||
|
|
||||||
wxMessageDialog dirErrorDlg( this, msg, _( "Error" ), wxOK_DEFAULT | wxICON_ERROR );
|
wxMessageDialog dirErrorDlg( this, msg, _( "Error" ), wxOK_DEFAULT | wxICON_ERROR );
|
||||||
dirErrorDlg.ShowModal();
|
dirErrorDlg.ShowModal();
|
||||||
|
@ -130,14 +130,36 @@ void KICAD_MANAGER_FRAME::ImportNonKiCadProject( wxString aWindowTitle, wxString
|
||||||
wxFileName schCopy( pro );
|
wxFileName schCopy( pro );
|
||||||
schCopy.SetExt( aSchFileExtension );
|
schCopy.SetExt( aSchFileExtension );
|
||||||
|
|
||||||
if( sch.Exists() && !schCopy.SameAs( sch ) )
|
if( sch.Exists() && !schCopy.SameAs( sch )
|
||||||
wxCopyFile( sch.GetFullPath(), schCopy.GetFullPath(), true );
|
&& 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;
|
||||||
|
}
|
||||||
|
|
||||||
wxFileName pcbCopy( pro );
|
wxFileName pcbCopy( pro );
|
||||||
pcbCopy.SetExt( aPcbFileExtension );
|
pcbCopy.SetExt( aPcbFileExtension );
|
||||||
|
|
||||||
if( pcb.Exists() && !pcbCopy.SameAs( pcb ) )
|
if( pcb.Exists() && !pcbCopy.SameAs( pcb )
|
||||||
wxCopyFile( pcb.GetFullPath(), pcbCopy.GetFullPath(), true );
|
&& 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." ),
|
||||||
|
sch.GetFullPath(), schCopy.GetFullPath() );
|
||||||
|
|
||||||
|
wxMessageDialog brdCopyErrorDlg( this, msg, _( "Error" ), wxOK_DEFAULT | wxICON_ERROR );
|
||||||
|
brdCopyErrorDlg.ShowModal();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Close the project and make the new one
|
// Close the project and make the new one
|
||||||
CloseProject( true );
|
CloseProject( true );
|
||||||
|
|
Loading…
Reference in New Issue