diff --git a/common/basicframe.cpp b/common/basicframe.cpp index 1edef83300..b9d8896573 100644 --- a/common/basicframe.cpp +++ b/common/basicframe.cpp @@ -692,7 +692,7 @@ void EDA_BASE_FRAME::CheckForAutoSaveFile( const wxFileName& aFileName, wxFileName autoSaveFileName = aFileName; // Check for auto save file. - autoSaveFileName.SetName( wxT( "$" ) + aFileName.GetName() ); + autoSaveFileName.SetName( AUTOSAVE_PREFIX_FILENAME + aFileName.GetName() ); wxLogTrace( traceAutoSave, wxT( "Checking for auto save file " ) + autoSaveFileName.GetFullPath() ); @@ -701,9 +701,10 @@ void EDA_BASE_FRAME::CheckForAutoSaveFile( const wxFileName& aFileName, return; wxString msg = wxString::Format( _( - "Well this is potentially embarrassing! It appears that the last time " - "you were editing the file '%s' it was not saved properly. Do you wish to restore the last " - "edits you made?" ), + "Well this is potentially embarrassing!\n" + "It appears that the last time you were editing the file\n" + "'%s'\n" + "it was not saved properly. Do you wish to restore the last saved edits you made?" ), GetChars( aFileName.GetFullName() ) ); diff --git a/common/project.cpp b/common/project.cpp index ff3d853ebc..b2fb30d12b 100644 --- a/common/project.cpp +++ b/common/project.cpp @@ -357,7 +357,6 @@ const wxString PROJECT::AbsolutePath( const wxString& aFileName ) const if( !fn.IsAbsolute() ) { wxString pro_dir = wxPathOnly( GetProjectFullName() ); - fn.Normalize( wxPATH_NORM_ALL, pro_dir ); } diff --git a/eeschema/files-io.cpp b/eeschema/files-io.cpp index 2058d63a55..4ef6572b3f 100644 --- a/eeschema/files-io.cpp +++ b/eeschema/files-io.cpp @@ -121,7 +121,7 @@ bool SCH_EDIT_FRAME::SaveEEFile( SCH_SCREEN* aScreen, bool aSaveUnderNewName, bo { // Delete auto save file. wxFileName autoSaveFileName = schematicFileName; - autoSaveFileName.SetName( wxT( "$" ) + schematicFileName.GetName() ); + autoSaveFileName.SetName( AUTOSAVE_PREFIX_FILENAME + schematicFileName.GetName() ); if( autoSaveFileName.FileExists() ) { @@ -520,8 +520,8 @@ bool SCH_EDIT_FRAME::doAutoSave() tmpFileName = fn = screen->GetFileName(); - // Auto save file name is the normal file name prefixed with $. - fn.SetName( wxT( "$" ) + fn.GetName() ); + // Auto save file name is the normal file name prefixed with AUTOSAVE_PREFIX_FILENAME. + fn.SetName( AUTOSAVE_PREFIX_FILENAME + fn.GetName() ); screen->SetFileName( fn.GetFullPath() ); diff --git a/eeschema/load_one_schematic_file.cpp b/eeschema/load_one_schematic_file.cpp index bf2edd307a..1bca27f4a7 100644 --- a/eeschema/load_one_schematic_file.cpp +++ b/eeschema/load_one_schematic_file.cpp @@ -66,15 +66,7 @@ bool SCH_EDIT_FRAME::LoadOneEEFile( SCH_SCREEN* aScreen, const wxString& aFullFi if( aFullFileName.IsEmpty() ) return false; - fn = aFullFileName; - CheckForAutoSaveFile( fn, SchematicBackupFileExtension ); - - wxLogTrace( traceAutoSave, wxT( "Loading schematic file " ) + aFullFileName ); - - aScreen->SetCurItem( NULL ); - if( !append ) - aScreen->SetFileName( aFullFileName ); - + // If path is relative, this expands it from the project directory. wxString fname = Prj().AbsolutePath( aFullFileName ); #ifdef __WINDOWS__ @@ -83,6 +75,15 @@ bool SCH_EDIT_FRAME::LoadOneEEFile( SCH_SCREEN* aScreen, const wxString& aFullFi fname.Replace( wxT("\\"), wxT("/") ); #endif + fn = fname; + CheckForAutoSaveFile( fn, SchematicBackupFileExtension ); + + wxLogTrace( traceAutoSave, wxT( "Loading schematic file " ) + aFullFileName ); + + aScreen->SetCurItem( NULL ); + if( !append ) + aScreen->SetFileName( aFullFileName ); + FILE* f = wxFopen( fname, wxT( "rt" ) ); if( !f ) diff --git a/eeschema/schframe.cpp b/eeschema/schframe.cpp index e3927e5808..285518b0cf 100644 --- a/eeschema/schframe.cpp +++ b/eeschema/schframe.cpp @@ -634,8 +634,8 @@ void SCH_EDIT_FRAME::OnCloseWindow( wxCloseEvent& aEvent ) { fn = Prj().AbsolutePath( screen->GetFileName() ); - // Auto save file name is the normal file name prepended with $. - fn.SetName( wxT( "$" ) + fn.GetName() ); + // Auto save file name is the normal file name prepended with AUTOSAVE_PREFIX_FILENAME. + fn.SetName( AUTOSAVE_PREFIX_FILENAME + fn.GetName() ); if( fn.FileExists() && fn.IsFileWritable() ) wxRemoveFile( fn.GetFullPath() ); diff --git a/include/wxstruct.h b/include/wxstruct.h index 19a9fb6cd4..70bc42f2d6 100644 --- a/include/wxstruct.h +++ b/include/wxstruct.h @@ -60,6 +60,16 @@ #define CREATE_BACKUP_FILE true #define NO_BACKUP_FILE false +/** + * a prefix to create filenames for schematic files or other difile when auto-saved + * to retrieve a crash + * The auto-saved filenames are AUTOSAVE_PREFIX_FILENAME + + * where is the flename without path of the auto-saved file + * Warning: avoid any special char like / \ $ % which can create issues on Unix + * or Window with filenames or env var expansion. + */ +#define AUTOSAVE_PREFIX_FILENAME wxT( "_saved_" ) + class EDA_ITEM; class EDA_RECT;