diff --git a/kicad/kicad_manager_frame.cpp b/kicad/kicad_manager_frame.cpp index c9236199df..3135f9f185 100644 --- a/kicad/kicad_manager_frame.cpp +++ b/kicad/kicad_manager_frame.cpp @@ -612,7 +612,10 @@ void KICAD_MANAGER_FRAME::LoadProject( const wxFileName& aProjectFileName ) if( aProjectFileName.IsDirWritable() ) SetMruPath( Prj().GetProjectPath() ); // Only set MRU path if we have write access. Why? - UpdateFileHistory( Prj().GetProjectFullName() ); + // Save history & window state to disk now. Don't wait around for a crash. + KICAD_SETTINGS* settings = kicadSettings(); + SaveSettings( settings ); + settings->SaveToFile( Pgm().GetSettingsManager().GetPathForSettingsFile( settings ) ); m_leftWin->ReCreateTreePrj(); @@ -713,7 +716,10 @@ void KICAD_MANAGER_FRAME::CreateNewProject( const wxFileName& aProjectFileName, } } - UpdateFileHistory( aProjectFileName.GetFullPath() ); + // Save history & window state to disk now. Don't wait around for a crash. + KICAD_SETTINGS* settings = kicadSettings(); + SaveSettings( settings ); + settings->SaveToFile( Pgm().GetSettingsManager().GetPathForSettingsFile( settings ) ); m_openSavedWindows = true; } @@ -832,6 +838,9 @@ void KICAD_MANAGER_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg ) wxCHECK( settings, /*void*/); settings->m_LeftWinWidth = m_leftWin->GetSize().x; + + if( !m_isClosing ) + settings->m_OpenProjects = GetSettingsManager()->GetOpenProjects(); } diff --git a/kicad/tools/kicad_manager_control.cpp b/kicad/tools/kicad_manager_control.cpp index 32076c6495..be525be578 100644 --- a/kicad/tools/kicad_manager_control.cpp +++ b/kicad/tools/kicad_manager_control.cpp @@ -743,6 +743,20 @@ int KICAD_MANAGER_CONTROL::ShowPlayer( const TOOL_EVENT& aEvent ) if( wxWindow::FindFocus() != player ) player->SetFocus(); + // Save window state to disk now. Don't wait around for a crash. + if( Pgm().GetCommonSettings()->m_Session.remember_open_files + && !player->GetCurrentFileName().IsEmpty() ) + { + wxFileName rfn( player->GetCurrentFileName() ); + rfn.MakeRelativeTo( Prj().GetProjectPath() ); + + WINDOW_SETTINGS windowSettings; + player->SaveWindowSettings( &windowSettings ); + + Prj().GetLocalSettings().SaveFileState( rfn.GetFullPath(), &windowSettings, true ); + Prj().GetLocalSettings().SaveToFile( Prj().GetProjectPath() ); + } + return 0; }