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

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
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -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() )
        );

+0 −1
Original line number Diff line number Diff line
@@ -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 );
    }

+3 −3
Original line number Diff line number Diff line
@@ -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() );

+10 −9
Original line number Diff line number Diff line
@@ -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 )
+2 −2
Original line number Diff line number Diff line
@@ -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() );
Loading