From bde103f5beddb904808f60ab78cc738ae6827587 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Thu, 20 Dec 2012 21:20:56 +0100 Subject: [PATCH] Pcbnew: fix issue when loading a recovery backup board file. Because now there are 2 formats, board backup files extensions are .brd-bak or .kicad_pcb-bak instead of the old .000 extension, depending on the initial file format. --- bitmaps_png/CMakeLists.txt | 1 - bitmaps_png/cpp_26/jigsaw.cpp | 39 ------------------------------- bitmaps_png/sources/jigsaw.svg | 8 ------- include/bitmaps.h | 1 - kicad/files-io.cpp | 6 ++--- pcbnew/files.cpp | 42 +++++++++++++++------------------- pcbnew/menubar_pcbframe.cpp | 8 +------ pcbnew/pcbframe.cpp | 1 - pcbnew/pcbnew_id.h | 1 - 9 files changed, 22 insertions(+), 85 deletions(-) delete mode 100644 bitmaps_png/cpp_26/jigsaw.cpp delete mode 100644 bitmaps_png/sources/jigsaw.svg diff --git a/bitmaps_png/CMakeLists.txt b/bitmaps_png/CMakeLists.txt index 6774e74e96..eb69a56293 100644 --- a/bitmaps_png/CMakeLists.txt +++ b/bitmaps_png/CMakeLists.txt @@ -302,7 +302,6 @@ set( BMAPS_MID insert_module_board invert_module invisible_text - jigsaw kicad_icon_small label2glabel label2text diff --git a/bitmaps_png/cpp_26/jigsaw.cpp b/bitmaps_png/cpp_26/jigsaw.cpp deleted file mode 100644 index 63eee77215..0000000000 --- a/bitmaps_png/cpp_26/jigsaw.cpp +++ /dev/null @@ -1,39 +0,0 @@ - -/* Do not modify this file, it was automatically generated by the - * PNG2cpp CMake script, using a *.png file as input. - */ - -#include - -static const unsigned char png[] = { - 0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d, 0x49, 0x48, 0x44, 0x52, - 0x00, 0x00, 0x00, 0x1a, 0x00, 0x00, 0x00, 0x1a, 0x08, 0x06, 0x00, 0x00, 0x00, 0xa9, 0x4a, 0x4c, - 0xce, 0x00, 0x00, 0x01, 0x5b, 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 0xce, 0xb5, 0xfb, - 0x27, 0xec, 0x63, 0x4a, 0x06, 0x29, 0x2c, 0x34, 0x02, 0x37, 0xc2, 0x0c, 0x0e, 0xf0, 0xa9, 0x26, - 0x33, 0x68, 0xa5, 0xf2, 0x52, 0xad, 0x41, 0x21, 0x37, 0x81, 0x49, 0xdc, 0x04, 0x44, 0x86, 0x51, - 0x1f, 0xb6, 0x22, 0x37, 0xa1, 0x69, 0xdc, 0x1b, 0x42, 0x8b, 0x51, 0xdf, 0xc8, 0xad, 0xc0, 0x3c, - 0x9e, 0x0d, 0xb1, 0x3d, 0x74, 0xd9, 0x0c, 0x89, 0x05, 0xfc, 0x18, 0x62, 0x6f, 0x18, 0xb5, 0x19, - 0x12, 0x67, 0x21, 0x83, 0x31, 0x64, 0x33, 0xb4, 0x65, 0x08, 0xc8, 0xb6, 0xf6, 0xa2, 0xcf, 0x66, - 0x68, 0x5c, 0x8d, 0xbc, 0x1e, 0x9a, 0xb3, 0xfd, 0x8d, 0xca, 0x4e, 0x7d, 0x21, 0x39, 0xf1, 0xb3, - 0x71, 0x42, 0xeb, 0x6a, 0x7c, 0xe3, 0x86, 0x4a, 0x86, 0xed, 0xbb, 0x46, 0x47, 0x54, 0x68, 0x16, - 0x45, 0x8c, 0xc5, 0x0c, 0x5d, 0x04, 0x0c, 0xc3, 0xb6, 0xed, 0xad, 0xf3, 0x9f, 0x14, 0x97, 0x58, - 0xc5, 0x95, 0x7e, 0xe0, 0xda, 0x08, 0x3d, 0xfa, 0x42, 0x79, 0xf5, 0x60, 0xf9, 0xa7, 0x6e, 0xb0, - 0x15, 0x2a, 0x18, 0xb6, 0xac, 0x58, 0x8d, 0xa9, 0xbb, 0x33, 0x84, 0x3e, 0x4c, 0x27, 0xf8, 0x1f, - 0x26, 0x39, 0xdf, 0x0d, 0x29, 0x3f, 0x4b, 0xd5, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, - 0xae, 0x42, 0x60, 0x82, -}; - -const BITMAP_OPAQUE jigsaw_xpm[1] = {{ png, sizeof( png ), "jigsaw_xpm" }}; - -//EOF diff --git a/bitmaps_png/sources/jigsaw.svg b/bitmaps_png/sources/jigsaw.svg deleted file mode 100644 index 4cb84414d5..0000000000 --- a/bitmaps_png/sources/jigsaw.svg +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/include/bitmaps.h b/include/bitmaps.h index 07946e02c0..3d77faee4b 100644 --- a/include/bitmaps.h +++ b/include/bitmaps.h @@ -223,7 +223,6 @@ EXTERN_BITMAP( info_xpm ) EXTERN_BITMAP( insert_module_board_xpm ) EXTERN_BITMAP( invert_module_xpm ) EXTERN_BITMAP( invisible_text_xpm ) -EXTERN_BITMAP( jigsaw_xpm ) EXTERN_BITMAP( kicad_icon_small_xpm ) EXTERN_BITMAP( label2glabel_xpm ) EXTERN_BITMAP( label2text_xpm ) diff --git a/kicad/files-io.cpp b/kicad/files-io.cpp index a3d54ee80f..ab8f5c8476 100644 --- a/kicad/files-io.cpp +++ b/kicad/files-io.cpp @@ -1,6 +1,6 @@ -/****************/ -/* files-io.cpp */ -/****************/ +/** + * @file kicad/files-io.cpp + */ /* * This program source code file is part of KiCad, a free EDA CAD application. diff --git a/pcbnew/files.cpp b/pcbnew/files.cpp index 98db17a7e7..d1797bc130 100644 --- a/pcbnew/files.cpp +++ b/pcbnew/files.cpp @@ -42,7 +42,6 @@ #include #include -#include #include #include #include @@ -51,9 +50,7 @@ #include // LEGACY_BOARD_FILE_VERSION -static const wxString pcbBackupFileExtension( wxT( "000" ) ); -static wxString saveFileName( wxT( "$savepcb" ) ); - +static const wxString backupFileExtensionSuffix( wxT( "-bak" ) ); void PCB_EDIT_FRAME::OnFileHistory( wxCommandEvent& event ) { @@ -89,29 +86,22 @@ void PCB_EDIT_FRAME::Files_io( wxCommandEvent& event ) break; case ID_MENU_READ_LAST_SAVED_VERSION_BOARD: - case ID_MENU_RECOVER_BOARD: { wxFileName fn; - - if( id == ID_MENU_RECOVER_BOARD ) - { - fn = wxFileName( wxEmptyString, saveFileName, PcbFileExtension ); - } - else - { - fn = GetBoard()->GetFileName(); - fn.SetExt( pcbBackupFileExtension ); - } + fn = GetBoard()->GetFileName(); + wxString backup_ext = fn.GetExt()+ backupFileExtensionSuffix; + fn.SetExt( backup_ext ); if( !fn.FileExists() ) { - msg = _( "Recovery file " ) + fn.GetFullPath() + _( " not found." ); + msg.Printf( _( "Recovery file <%s> not found." ), + GetChars( fn.GetFullPath() ) ); DisplayInfoMessage( this, msg ); break; } else { - msg = _( "OK to load recovery file " ) + fn.GetFullPath(); + msg.Printf( _( "OK to load recovery file <%s>" ), GetChars(fn.GetFullPath() ) ); if( !IsOK( this, msg ) ) break; @@ -224,10 +214,14 @@ the changes?" ) ) ) int chosenFilter = dlg.GetFilterIndex(); pluginType = loaders[chosenFilter].pluginType; } - else // if a filename is given, force IO_MGR::KICAD if the file est is kicad_pcb + else // if a filename is given, force IO_MGR::KICAD if the file ext is kicad_pcb // for instance if the filename comes from file history + // or it is a backup file with ext = kicad_pcb-bak { - if( fileName.GetExt() == IO_MGR::GetFileExtension( IO_MGR::KICAD ) ) + wxString backup_ext = IO_MGR::GetFileExtension( IO_MGR::KICAD ) + + backupFileExtensionSuffix; + if( fileName.GetExt() == IO_MGR::GetFileExtension( IO_MGR::KICAD ) || + fileName.GetExt() == backup_ext ) pluginType = IO_MGR::KICAD; } @@ -239,7 +233,7 @@ the changes?" ) ) ) if( !aAppend ) Clear_Pcb( false ); // pass false since we prompted above for a modified board - CheckForAutoSaveFile( fileName, pcbBackupFileExtension ); + CheckForAutoSaveFile( fileName, fileName.GetExt() ); GetBoard()->SetFileName( fileName.GetFullPath() ); @@ -282,9 +276,9 @@ the changes?" ) ) ) if( pluginType == IO_MGR::LEGACY && loadedBoard->GetFileFormatVersionAtLoad() < LEGACY_BOARD_FILE_VERSION ) { - DisplayInfoMessage( this, _( "This file was created by an older \ -version of Pcbnew. It will be stored in the new file format when you save \ -this file again." ) ); + DisplayInfoMessage( this, + _( "This file was created by an older version of Pcbnew.\ +\nIt will be stored in the new file format when you save this file again." ) ); } SetBoard( loadedBoard ); @@ -474,7 +468,7 @@ bool PCB_EDIT_FRAME::SavePcbFile( const wxString& aFileName, bool aCreateBackupF { // Get the backup file name backupFileName = pcbFileName; - backupFileName.SetExt( pcbBackupFileExtension ); + backupFileName.SetExt( pcbFileName.GetExt() + backupFileExtensionSuffix ); // If an old backup file exists, delete it. If an old board file exists, rename // it to the backup file name. diff --git a/pcbnew/menubar_pcbframe.cpp b/pcbnew/menubar_pcbframe.cpp index f3c36b6b88..9f700b52a9 100644 --- a/pcbnew/menubar_pcbframe.cpp +++ b/pcbnew/menubar_pcbframe.cpp @@ -115,15 +115,9 @@ void PCB_EDIT_FRAME::ReCreateMenuBar() AddMenuItem( filesMenu, ID_MENU_READ_LAST_SAVED_VERSION_BOARD, _( "Revert" ), _( "Clear board and get previous saved version of board" ), - KiBitmap( jigsaw_xpm ) ); - - // Rescue - AddMenuItem( filesMenu, ID_MENU_RECOVER_BOARD, _( "Rescue" ), - _( "Clear old board and get last rescue file" ), - KiBitmap( hammer_xpm ) ); + KiBitmap( help_xpm ) ); filesMenu->AppendSeparator(); - /* Fabrication Outputs submenu */ wxMenu* fabricationOutputsMenu = new wxMenu; AddMenuItem( fabricationOutputsMenu, ID_PCB_GEN_POS_MODULES_FILE, diff --git a/pcbnew/pcbframe.cpp b/pcbnew/pcbframe.cpp index a68c9c4562..781215e9cf 100644 --- a/pcbnew/pcbframe.cpp +++ b/pcbnew/pcbframe.cpp @@ -78,7 +78,6 @@ BEGIN_EVENT_TABLE( PCB_EDIT_FRAME, PCB_BASE_FRAME ) EVT_TOOL( ID_LOAD_FILE, PCB_EDIT_FRAME::Files_io ) EVT_TOOL( ID_MENU_READ_LAST_SAVED_VERSION_BOARD, PCB_EDIT_FRAME::Files_io ) - EVT_TOOL( ID_MENU_RECOVER_BOARD, PCB_EDIT_FRAME::Files_io ) EVT_TOOL( ID_NEW_BOARD, PCB_EDIT_FRAME::Files_io ) EVT_TOOL( ID_SAVE_BOARD, PCB_EDIT_FRAME::Files_io ) EVT_TOOL( ID_OPEN_MODULE_EDITOR, PCB_EDIT_FRAME::Process_Special_Functions ) diff --git a/pcbnew/pcbnew_id.h b/pcbnew/pcbnew_id.h index 685e872f57..700ac513d4 100644 --- a/pcbnew/pcbnew_id.h +++ b/pcbnew/pcbnew_id.h @@ -231,7 +231,6 @@ enum pcbnew_ids ID_POPUP_PCB_REORIENT_ALL_MODULES, - ID_MENU_RECOVER_BOARD, ID_MENU_READ_LAST_SAVED_VERSION_BOARD, ID_MENU_ARCHIVE_MODULES, ID_MENU_ARCHIVE_NEW_MODULES,