From 719be61627dbc8db28ac0e37f3c4a3f14db9ce85 Mon Sep 17 00:00:00 2001 From: Marek Roszko Date: Tue, 31 Jan 2023 20:57:31 -0500 Subject: [PATCH] Silence some kicad-cli loading errors on clean installs --- common/settings/settings_manager.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/common/settings/settings_manager.cpp b/common/settings/settings_manager.cpp index 684cdaa87f..9b610ef4f1 100644 --- a/common/settings/settings_manager.cpp +++ b/common/settings/settings_manager.cpp @@ -502,15 +502,24 @@ public: bool SETTINGS_MANAGER::MigrateIfNeeded() { + wxFileName path( GetUserSettingsPath(), wxS( "" ) ); + wxLogTrace( traceSettings, wxT( "Using settings path %s" ), path.GetFullPath() ); + if( m_headless ) { + // Special case namely for cli + // Ensure the settings directory at least exists to prevent additional loading errors from subdirectories + // TODO review headless (unit tests) vs cli needs, this should be fine for unit tests though + if( !path.DirExists() ) + { + wxLogTrace( traceSettings, wxT( "Path didn't exist; creating it" ) ); + path.Mkdir( wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL ); + } + wxLogTrace( traceSettings, wxT( "Settings migration not checked; running headless" ) ); return true; } - wxFileName path( GetUserSettingsPath(), wxS( "" ) ); - wxLogTrace( traceSettings, wxT( "Using settings path %s" ), path.GetFullPath() ); - if( path.DirExists() ) { wxFileName common = path;