Pcbnew: add missing file and directory overwrite prompts.

Fix the Specttra, VRML, and IDF export dialogs to prompt the user when they
are about to overwrite and existing file and/or folders.

Fixes lp:1706235

https://bugs.launchpad.net/kicad/+bug/1706235
This commit is contained in:
Wayne Stambaugh 2017-08-02 13:30:57 -04:00
parent 42b70b86f2
commit 9760937494
3 changed files with 40 additions and 11 deletions

View File

@ -6,6 +6,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2013-2015 Cirilo Bernardo
* Copyright (C) 2013-2017 KiCad Developers, see change_log.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
@ -45,7 +46,6 @@
class DIALOG_EXPORT_IDF3: public DIALOG_EXPORT_IDF3_BASE
{
private:
PCB_EDIT_FRAME* m_parent;
wxConfigBase* m_config;
bool m_idfThouOpt; // remember last preference for units in THOU
bool m_AutoAdjust; // remember last Reference Point AutoAdjust setting
@ -57,7 +57,6 @@ public:
DIALOG_EXPORT_IDF3( PCB_EDIT_FRAME* parent ) :
DIALOG_EXPORT_IDF3_BASE( parent )
{
m_parent = parent;
m_config = Kiface().KifaceSettings();
SetFocus();
m_idfThouOpt = false;
@ -156,13 +155,25 @@ public:
event.Skip();
}
bool TransferDataFromWindow() override;
};
/**
* Function OnExportIDF3
* will export the current BOARD to IDF board and lib files.
*/
bool DIALOG_EXPORT_IDF3::TransferDataFromWindow()
{
wxFileName fn = m_filePickerIDF->GetPath();
if( fn.FileExists() )
{
if( wxMessageBox( _( "Are you sure you want to overwrite the exiting file?" ),
_( "Warning" ), wxYES_NO | wxCENTER | wxICON_QUESTION, this ) == wxNO )
return false;
}
return true;
}
void PCB_EDIT_FRAME::OnExportIDF3( wxCommandEvent& event )
{
wxFileName fn;

View File

@ -7,7 +7,7 @@
*
* Copyright (C) 2009-2013 Lorenzo Mercantonio
* Copyright (C) 2013 Jean-Pierre Charras jp.charras at wanadoo.fr
* Copyright (C) 2004-2015 KiCad Developers, see change_log.txt for contributors.
* Copyright (C) 2004-2017 KiCad Developers, see change_log.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
@ -26,9 +26,12 @@
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <wx/dir.h>
#include <fctsys.h>
#include <wxPcbStruct.h>
#include <kiface_i.h>
#include <pcbnew.h>
#include <class_board.h>
@ -50,7 +53,6 @@
class DIALOG_EXPORT_3DFILE : public DIALOG_EXPORT_3DFILE_BASE
{
private:
PCB_EDIT_FRAME* m_parent;
wxConfigBase* m_config;
int m_unitsOpt; // Remember last units option
bool m_copy3DFilesOpt; // Remember last copy model files option
@ -64,7 +66,6 @@ public:
DIALOG_EXPORT_3DFILE( PCB_EDIT_FRAME* parent ) :
DIALOG_EXPORT_3DFILE_BASE( parent )
{
m_parent = parent;
m_config = Kiface().KifaceSettings();
m_filePicker->SetFocus();
m_config->Read( OPTKEY_OUTPUT_UNIT, &m_unitsOpt, 1 );
@ -162,9 +163,26 @@ public:
// Making path relative or absolute has no meaning when VRML files are not copied.
event.Enable( m_cbCopyFiles->GetValue() );
}
bool TransferDataFromWindow() override;
};
bool DIALOG_EXPORT_3DFILE::TransferDataFromWindow()
{
wxFileName fn = m_filePicker->GetPath();
if( fn.Exists() )
{
if( wxMessageBox( _( "Are you sure you want to overwrite the exiting file(s)?" ),
_( "Warning" ), wxYES_NO | wxCENTER | wxICON_QUESTION, this ) == wxNO )
return false;
}
return true;
}
void PCB_EDIT_FRAME::OnExportVRML( wxCommandEvent& event )
{
// These variables are static to keep info during the session.

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2007-2015 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2015-2016 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2015-2017 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
@ -91,7 +91,7 @@ void PCB_EDIT_FRAME::ExportToSpecctra( wxCommandEvent& event )
dsn_ext,
mask,
this,
wxFD_SAVE,
wxFD_SAVE | wxFD_OVERWRITE_PROMPT,
false );
if( fullFileName == wxEmptyString )