From 2f3c5e7a1ed485801f72d8bfd50d396eaeac2b5d Mon Sep 17 00:00:00 2001 From: Jacobo Aragunde Perez Date: Mon, 21 Jan 2013 20:58:02 +0100 Subject: [PATCH] Eeschema: fix Bug #1102381 --- eeschema/files-io.cpp | 10 +++++----- eeschema/libarch.cpp | 15 +++++++++++++++ include/wxEeschemaStruct.h | 9 +++++++++ 3 files changed, 29 insertions(+), 5 deletions(-) diff --git a/eeschema/files-io.cpp b/eeschema/files-io.cpp index 18858d994d..1004d803d3 100644 --- a/eeschema/files-io.cpp +++ b/eeschema/files-io.cpp @@ -166,7 +166,10 @@ void SCH_EDIT_FRAME::Save_File( wxCommandEvent& event ) break; case ID_SAVE_ONE_SHEET_UNDER_NEW_NAME: - SaveEEFile( NULL, true ); + if( SaveEEFile( NULL, true ) ) + { + CreateArchiveLibraryCacheFile(); + } break; } } @@ -377,10 +380,7 @@ void SCH_EDIT_FRAME::OnSaveProject( wxCommandEvent& aEvent ) for( screen = ScreenList.GetFirst(); screen != NULL; screen = ScreenList.GetNext() ) SaveEEFile( screen ); - wxString cachename = fn.GetName() + wxT( "-cache" ); - fn.SetName( cachename ); - fn.SetExt( SchematicLibraryFileExtension ); - CreateArchiveLibrary( fn.GetFullPath() ); + CreateArchiveLibraryCacheFile(); } diff --git a/eeschema/libarch.cpp b/eeschema/libarch.cpp index 399e00f31c..fca168e051 100644 --- a/eeschema/libarch.cpp +++ b/eeschema/libarch.cpp @@ -40,6 +40,21 @@ #include #include #include +#include +#include + + +bool SCH_EDIT_FRAME::CreateArchiveLibraryCacheFile() +{ + wxFileName fn; + SCH_SCREENS ScreenList; + + fn = ScreenList.GetFirst()->GetFileName(); + fn.SetName( fn.GetName() + wxT( "-cache" ) ); + fn.SetExt( SchematicLibraryFileExtension ); + + return CreateArchiveLibrary( fn.GetFullPath() ); +} bool SCH_EDIT_FRAME::CreateArchiveLibrary( const wxString& aFileName ) diff --git a/include/wxEeschemaStruct.h b/include/wxEeschemaStruct.h index 56114a862a..73d15325c2 100644 --- a/include/wxEeschemaStruct.h +++ b/include/wxEeschemaStruct.h @@ -1167,6 +1167,15 @@ public: */ void LoadLibraries( void ); + /** + * Function CreateArchiveLibraryCacheFile + * creates a library file with the name of the root document plus the '-cache' suffix, + * That file will contain all components used in the current schematic. + * + * @return True if the file was written successfully. + */ + bool CreateArchiveLibraryCacheFile( void ); + /** * Function CreateArchiveLibrary * creates a library \a aFileName that contains all components used in the current schematic.