Commit 722435f3 authored by jp charras's avatar jp charras Committed by jean-pierre charras

Fix issues in auto-save files:

* auto-save was broken for all sub sheets with are in a sub-directory of the project directory. (reason wxFileName::Normalize(), used to create the absolute path  has issues with filenames starting by '$', perhaps due to env var which also start by $). the auto-save prefix is modified ( now AUTOSAVE_PREFIX_FILENAME which defines "_save_"  ) and defined only once.
* auto-save files from sub-sheets were not found due to the fact the path was not set (fixed by Blair Bonnet's patch)
parent d41bc31c
......@@ -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() )
);
......
......@@ -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 );
}
......
......@@ -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() );
......
......@@ -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 )
......
......@@ -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() );
......
......@@ -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 + <sourcefilename>
* where <sourcefilename> 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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment