From 09e8f721962748701d5de3e862933058414680f4 Mon Sep 17 00:00:00 2001 From: Jon Evans Date: Sun, 7 May 2023 21:46:39 -0400 Subject: [PATCH] Don't try to open files multiple times Fixes https://gitlab.com/kicad/code/kicad/-/issues/14703 --- common/project/project_local_settings.cpp | 2 ++ kicad/kicad_manager_frame.cpp | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/common/project/project_local_settings.cpp b/common/project/project_local_settings.cpp index 272a5c00ee..acc283538d 100644 --- a/common/project/project_local_settings.cpp +++ b/common/project/project_local_settings.cpp @@ -210,6 +210,8 @@ PROJECT_LOCAL_SETTINGS::PROJECT_LOCAL_SETTINGS( PROJECT* aProject, const wxStrin return; } + m_files.clear(); + for( const nlohmann::json& file : aVal ) { PROJECT_FILE_STATE fileState; diff --git a/kicad/kicad_manager_frame.cpp b/kicad/kicad_manager_frame.cpp index 223b607a78..2cf9ae8e8e 100644 --- a/kicad/kicad_manager_frame.cpp +++ b/kicad/kicad_manager_frame.cpp @@ -864,15 +864,19 @@ void KICAD_MANAGER_FRAME::OnIdle( wxIdleEvent& aEvent ) APP_PROGRESS_DIALOG progressReporter( _( "Restoring session" ), wxEmptyString, previousOpenCount, this ); + // We don't currently support opening more than one view per file + std::set openedFiles; + int i = 0; for( const PROJECT_FILE_STATE& file : Prj().GetLocalSettings().m_files ) { - if( file.open ) + if( file.open && !openedFiles.count( file.fileName ) ) { progressReporter.Update( i++, wxString::Format( _( "Restoring '%s'" ), file.fileName ) ); + openedFiles.insert( file.fileName ); wxFileName fn( file.fileName ); if( fn.GetExt() == LegacySchematicFileExtension