diff --git a/include/wxPcbStruct.h b/include/wxPcbStruct.h index ecdf62fce1..9a345eed16 100644 --- a/include/wxPcbStruct.h +++ b/include/wxPcbStruct.h @@ -849,10 +849,28 @@ public: /** * Function Files_io - * is the command event handler for read and write file commands. + * @param event is the command event handler. + * do nothing else than call Files_io_from_id with the + * wxCommandEvent id */ void Files_io( wxCommandEvent& event ); + /** + * Function Files_io_from_id + * Read and write board files + * @param aId is an event ID ciming from file command events: + * ID_LOAD_FILE + * ID_MENU_READ_BOARD_BACKUP_FILE + * ID_MENU_RECOVER_BOARD_AUTOSAVE + * ID_APPEND_FILE + * ID_NEW_BOARD + * ID_SAVE_BOARD + * ID_COPY_BOARD_AS + * ID_SAVE_BOARD_AS + * Files_io_from_id prepare parameters and calls the specialized function + */ + void Files_io_from_id( int aId ); + /** * Function OpenProjectFiles (was LoadOnePcbFile) * loads a KiCad board (.kicad_pcb) from \a aFileName. diff --git a/pcbnew/files.cpp b/pcbnew/files.cpp index 5796d8ffcd..c9d7df189d 100644 --- a/pcbnew/files.cpp +++ b/pcbnew/files.cpp @@ -1,9 +1,9 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2004-2010 Jean-Pierre Charras, jean-pierre.charras@gpisa-lab.inpg.fr + * Copyright (C) 2004-2015 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2011 Wayne Stambaugh - * Copyright (C) 2010 KiCad Developers, see change_log.txt for contributors. + * Copyright (C) 2015 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 @@ -222,6 +222,11 @@ void PCB_EDIT_FRAME::OnFileHistory( wxCommandEvent& event ) void PCB_EDIT_FRAME::Files_io( wxCommandEvent& event ) { int id = event.GetId(); + Files_io_from_id( id ); +} + +void PCB_EDIT_FRAME::Files_io_from_id( int id ) +{ wxString msg; // If an edition is in progress, stop it. @@ -326,9 +331,9 @@ void PCB_EDIT_FRAME::Files_io( wxCommandEvent& event ) SavePcbFile( Prj().AbsolutePath( GetBoard()->GetFileName() ) ); break; } - // Fall through - case ID_COPY_BOARD_AS: - case ID_SAVE_BOARD_AS: + // Fall through + case ID_COPY_BOARD_AS: + case ID_SAVE_BOARD_AS: { wxString pro_dir = wxPathOnly( Prj().GetProjectFullName() ); wxFileName fn( pro_dir, _( "noname" ), KiCadPcbFileExtension ); diff --git a/pcbnew/pcbframe.cpp b/pcbnew/pcbframe.cpp index 50af8f08a6..f82c5d4c46 100644 --- a/pcbnew/pcbframe.cpp +++ b/pcbnew/pcbframe.cpp @@ -595,7 +595,9 @@ void PCB_EDIT_FRAME::OnCloseWindow( wxCloseEvent& Event ) break; case wxID_YES: - SavePcbFile( GetBoard()->GetFileName() ); + // save the board. if the board has no name, + // the ID_SAVE_BOARD_AS will actually made + Files_io_from_id( ID_SAVE_BOARD ); break; } }