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 Original line Diff line number Diff line
@@ -692,7 +692,7 @@ void EDA_BASE_FRAME::CheckForAutoSaveFile( const wxFileName& aFileName,
    wxFileName autoSaveFileName = aFileName;
    wxFileName autoSaveFileName = aFileName;


    // Check for auto save file.
    // Check for auto save file.
    autoSaveFileName.SetName( wxT( "$" ) + aFileName.GetName() );
    autoSaveFileName.SetName( AUTOSAVE_PREFIX_FILENAME + aFileName.GetName() );


    wxLogTrace( traceAutoSave,
    wxLogTrace( traceAutoSave,
                wxT( "Checking for auto save file " ) + autoSaveFileName.GetFullPath() );
                wxT( "Checking for auto save file " ) + autoSaveFileName.GetFullPath() );
@@ -701,9 +701,10 @@ void EDA_BASE_FRAME::CheckForAutoSaveFile( const wxFileName& aFileName,
        return;
        return;


    wxString msg = wxString::Format( _(
    wxString msg = wxString::Format( _(
            "Well this is potentially embarrassing!  It appears that the last time "
            "Well this is potentially embarrassing!\n"
            "you were editing the file '%s' it was not saved properly.  Do you wish to restore the last "
            "It appears that the last time you were editing the file\n"
            "edits you made?" ),
            "'%s'\n"
            "it was not saved properly.  Do you wish to restore the last saved edits you made?" ),
            GetChars( aFileName.GetFullName() )
            GetChars( aFileName.GetFullName() )
        );
        );


+0 −1
Original line number Original line Diff line number Diff line
@@ -357,7 +357,6 @@ const wxString PROJECT::AbsolutePath( const wxString& aFileName ) const
    if( !fn.IsAbsolute() )
    if( !fn.IsAbsolute() )
    {
    {
        wxString pro_dir = wxPathOnly( GetProjectFullName() );
        wxString pro_dir = wxPathOnly( GetProjectFullName() );

        fn.Normalize( wxPATH_NORM_ALL, pro_dir );
        fn.Normalize( wxPATH_NORM_ALL, pro_dir );
    }
    }


+3 −3
Original line number Original line Diff line number Diff line
@@ -121,7 +121,7 @@ bool SCH_EDIT_FRAME::SaveEEFile( SCH_SCREEN* aScreen, bool aSaveUnderNewName, bo
    {
    {
        // Delete auto save file.
        // Delete auto save file.
        wxFileName autoSaveFileName = schematicFileName;
        wxFileName autoSaveFileName = schematicFileName;
        autoSaveFileName.SetName( wxT( "$" ) + schematicFileName.GetName() );
        autoSaveFileName.SetName( AUTOSAVE_PREFIX_FILENAME + schematicFileName.GetName() );


        if( autoSaveFileName.FileExists() )
        if( autoSaveFileName.FileExists() )
        {
        {
@@ -520,8 +520,8 @@ bool SCH_EDIT_FRAME::doAutoSave()


        tmpFileName = fn = screen->GetFileName();
        tmpFileName = fn = screen->GetFileName();


        // Auto save file name is the normal file name prefixed with $.
        // Auto save file name is the normal file name prefixed with AUTOSAVE_PREFIX_FILENAME.
        fn.SetName( wxT( "$" ) + fn.GetName() );
        fn.SetName( AUTOSAVE_PREFIX_FILENAME + fn.GetName() );


        screen->SetFileName( fn.GetFullPath() );
        screen->SetFileName( fn.GetFullPath() );


+10 −9
Original line number Original line Diff line number Diff line
@@ -66,15 +66,7 @@ bool SCH_EDIT_FRAME::LoadOneEEFile( SCH_SCREEN* aScreen, const wxString& aFullFi
    if( aFullFileName.IsEmpty() )
    if( aFullFileName.IsEmpty() )
        return false;
        return false;


    fn = aFullFileName;
    // If path is relative, this expands it from the project directory.
    CheckForAutoSaveFile( fn, SchematicBackupFileExtension );

    wxLogTrace( traceAutoSave, wxT( "Loading schematic file " ) + aFullFileName );

    aScreen->SetCurItem( NULL );
    if( !append )
        aScreen->SetFileName( aFullFileName );

    wxString fname = Prj().AbsolutePath( aFullFileName );
    wxString fname = Prj().AbsolutePath( aFullFileName );


#ifdef __WINDOWS__
#ifdef __WINDOWS__
@@ -83,6 +75,15 @@ bool SCH_EDIT_FRAME::LoadOneEEFile( SCH_SCREEN* aScreen, const wxString& aFullFi
    fname.Replace( wxT("\\"), wxT("/") );
    fname.Replace( wxT("\\"), wxT("/") );
#endif
#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" ) );
    FILE* f = wxFopen( fname, wxT( "rt" ) );


    if( !f )
    if( !f )
+2 −2
Original line number Original line Diff line number Diff line
@@ -634,8 +634,8 @@ void SCH_EDIT_FRAME::OnCloseWindow( wxCloseEvent& aEvent )
    {
    {
        fn = Prj().AbsolutePath( screen->GetFileName() );
        fn = Prj().AbsolutePath( screen->GetFileName() );


        // Auto save file name is the normal file name prepended with $.
        // Auto save file name is the normal file name prepended with AUTOSAVE_PREFIX_FILENAME.
        fn.SetName( wxT( "$" ) + fn.GetName() );
        fn.SetName( AUTOSAVE_PREFIX_FILENAME + fn.GetName() );


        if( fn.FileExists() && fn.IsFileWritable() )
        if( fn.FileExists() && fn.IsFileWritable() )
            wxRemoveFile( fn.GetFullPath() );
            wxRemoveFile( fn.GetFullPath() );
Loading