diff --git a/common/eda_base_frame.cpp b/common/eda_base_frame.cpp index 7d780a445d..a9ec9f24cb 100644 --- a/common/eda_base_frame.cpp +++ b/common/eda_base_frame.cpp @@ -453,6 +453,7 @@ void EDA_BASE_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVars void EDA_BASE_FRAME::LoadWindowState( const wxString& aFileName ) { const PROJECT_FILE_STATE* state = Prj().GetLocalSettings().GetFileState( aFileName ); + if( state != nullptr ) { LoadWindowState( state->window ); diff --git a/eeschema/libedit/lib_edit_frame.cpp b/eeschema/libedit/lib_edit_frame.cpp index a99d8f8e99..89ad10ce13 100644 --- a/eeschema/libedit/lib_edit_frame.cpp +++ b/eeschema/libedit/lib_edit_frame.cpp @@ -430,7 +430,7 @@ void LIB_EDIT_FRAME::setupUIConditions() } -bool LIB_EDIT_FRAME::canCloseWindow(wxCloseEvent& aEvent) +bool LIB_EDIT_FRAME::canCloseWindow( wxCloseEvent& aEvent ) { // Shutdown blocks must be determined and vetoed as early as possible if( SupportsShutdownBlockReason() && aEvent.GetId() == wxEVT_QUERY_END_SESSION diff --git a/include/eda_base_frame.h b/include/eda_base_frame.h index d75e5c65b0..5e4ced4bff 100644 --- a/include/eda_base_frame.h +++ b/include/eda_base_frame.h @@ -657,7 +657,11 @@ public: int GetMaxUndoItems() const { return m_UndoRedoCountMax; } - bool NonUserClose( bool aForce ) { m_isNonUserClose = true; return Close( aForce ); }; + bool NonUserClose( bool aForce ) + { + m_isNonUserClose = true; + return Close( aForce ); + } }; diff --git a/include/settings/json_settings.h b/include/settings/json_settings.h index c72682fc18..a768bcf5f8 100644 --- a/include/settings/json_settings.h +++ b/include/settings/json_settings.h @@ -190,7 +190,8 @@ c * @return true if the file was saved * @param aTarget is the storage destination * @return True if set, false if not */ - static bool SetIfPresent( const nlohmann::json& aObj, const std::string& aPath, wxString& aTarget ); + static bool SetIfPresent( const nlohmann::json& aObj, const std::string& aPath, + wxString& aTarget ); /** * Sets the given bool if the given key/path is present @@ -214,7 +215,8 @@ c * @return true if the file was saved * @param aTarget is the storage destination * @return True if set, false if not */ - static bool SetIfPresent( const nlohmann::json& aObj, const std::string& aPath, unsigned int& aTarget ); + static bool SetIfPresent( const nlohmann::json& aObj, const std::string& aPath, + unsigned int& aTarget ); protected: /** diff --git a/kicad/kicad_manager_frame.cpp b/kicad/kicad_manager_frame.cpp index af729654eb..20f6042e69 100644 --- a/kicad/kicad_manager_frame.cpp +++ b/kicad/kicad_manager_frame.cpp @@ -648,59 +648,68 @@ void KICAD_MANAGER_FRAME::PrintPrjInfo() PrintMsg( msg ); } + bool KICAD_MANAGER_FRAME::IsProjectActive() { return m_active_project; } + void KICAD_MANAGER_FRAME::OnIdle( wxIdleEvent& aEvent ) { /** - * We start loading the saved previously open windows on idle to avoid locking up the GUI earlier in project loading - * This gives us the visual effect of a opened KiCad project but with a "busy" progress reporter + * We start loading the saved previously open windows on idle to avoid locking up the GUI + * earlier in project loading. This gives us the visual effect of a opened KiCad project but + * with a "busy" progress reporter */ - if( m_openSavedWindows ) + if( !m_openSavedWindows ) + return; + + m_openSavedWindows = false; + + if( Pgm().GetCommonSettings()->m_Session.remember_open_files ) { - m_openSavedWindows = false; - if ( Pgm().GetCommonSettings()->m_Session.remember_open_files ) + int previousOpenCount = + std::count_if( Prj().GetLocalSettings().m_files.begin(), + Prj().GetLocalSettings().m_files.end(), + [&]( const PROJECT_FILE_STATE& f ) + { + return !f.fileName.EndsWith( ProjectFileExtension ) && f.open; + } ); + + if( previousOpenCount > 0 ) { - int previousOpenCount = std::count_if( Prj().GetLocalSettings().m_files.begin(), - Prj().GetLocalSettings().m_files.end(), - [&]( const PROJECT_FILE_STATE& f ) - { - return !f.fileName.EndsWith( ProjectFileExtension ) && f.open; - } ); - if ( previousOpenCount > 0 ) + APP_PROGRESS_DIALOG progressReporter( _( "Restoring session" ), wxEmptyString, + previousOpenCount, this ); + + int i = 0; + + for( const PROJECT_FILE_STATE& file : Prj().GetLocalSettings().m_files ) { - APP_PROGRESS_DIALOG progressReporter( _( "Restoring session" ), wxEmptyString, previousOpenCount, this ); - - int i = 0; - for( const PROJECT_FILE_STATE& file : Prj().GetLocalSettings().m_files ) + if( file.open ) { - if( file.open ) + progressReporter.Update( i++, + wxString::Format( _( "Restoring \"%s\"" ), file.fileName ) ); + + wxFileName fn( file.fileName ); + + if( fn.GetExt() == LegacySchematicFileExtension + || fn.GetExt() == KiCadSchematicFileExtension ) { - progressReporter.Update( - i++, wxString::Format( _( "Restoring \"%s\"" ), file.fileName ) ); - - wxFileName fn( file.fileName ); - if( fn.GetExt() == LegacySchematicFileExtension - || fn.GetExt() == KiCadSchematicFileExtension ) - { - GetToolManager()->RunAction( KICAD_MANAGER_ACTIONS::editSchematic, true ); - } - else if( fn.GetExt() == LegacyPcbFileExtension - || fn.GetExt() == KiCadPcbFileExtension ) - { - GetToolManager()->RunAction( KICAD_MANAGER_ACTIONS::editPCB, true ); - } + GetToolManager()->RunAction( KICAD_MANAGER_ACTIONS::editSchematic, true ); + } + else if( fn.GetExt() == LegacyPcbFileExtension + || fn.GetExt() == KiCadPcbFileExtension ) + { + GetToolManager()->RunAction( KICAD_MANAGER_ACTIONS::editPCB, true ); } - - wxYield(); } + + wxYield(); } } - - // clear file states regardless if we opened windows or not due to setting - Prj().GetLocalSettings().ClearFileState(); } -} \ No newline at end of file + + // clear file states regardless if we opened windows or not due to setting + Prj().GetLocalSettings().ClearFileState(); +} diff --git a/pcbnew/pcb_edit_frame.cpp b/pcbnew/pcb_edit_frame.cpp index ae821e8f24..f85bee3a52 100644 --- a/pcbnew/pcb_edit_frame.cpp +++ b/pcbnew/pcb_edit_frame.cpp @@ -812,7 +812,10 @@ bool PCB_EDIT_FRAME::canCloseWindow( wxCloseEvent& aEvent ) wxString msg = _( "Save changes to \"%s\" before closing?" ); if( !HandleUnsavedChanges( this, wxString::Format( msg, fileName.GetFullName() ), - [&]()->bool { return Files_io_from_id( ID_SAVE_BOARD ); } ) ) + [&]() -> bool + { + return Files_io_from_id( ID_SAVE_BOARD ); + } ) ) { return false; }