From 6a37f99e946cf742d21fe0ef1135cc48fd2eed96 Mon Sep 17 00:00:00 2001 From: Marek Roszko Date: Sun, 11 Feb 2024 21:04:09 -0500 Subject: [PATCH] Fix crash if we exit lib table setup Fixes https://gitlab.com/kicad/code/kicad/-/issues/16917 --- cvpcb/cvpcb.cpp | 3 +++ eeschema/eeschema.cpp | 8 +++++++- pcbnew/pcbnew.cpp | 14 ++++++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/cvpcb/cvpcb.cpp b/cvpcb/cvpcb.cpp index 6e83e92429..cc59a8141a 100644 --- a/cvpcb/cvpcb.cpp +++ b/cvpcb/cvpcb.cpp @@ -219,6 +219,9 @@ bool IFACE::OnKifaceStart( PGM_BASE* aProgram, int aCtlBits, KIWAY* aKiway ) } catch( const IO_ERROR& ioe ) { + // we didnt get anywhere deregister the settings + aProgram->GetSettingsManager().FlushAndRelease( KifaceSettings(), false ); + DisplayErrorMessage( nullptr, _( "An error occurred attempting to load the global " "footprint library table." ), ioe.What() ); diff --git a/eeschema/eeschema.cpp b/eeschema/eeschema.cpp index eb4b6e5e9d..006bda132b 100644 --- a/eeschema/eeschema.cpp +++ b/eeschema/eeschema.cpp @@ -381,7 +381,8 @@ bool IFACE::OnKifaceStart( PGM_BASE* aProgram, int aCtlBits, KIWAY* aKiway ) // Register the symbol editor settings as well because they share a KiFACE and need to be // loaded prior to use to avoid threading deadlocks - aProgram->GetSettingsManager().RegisterSettings( new SYMBOL_EDITOR_SETTINGS ); + SYMBOL_EDITOR_SETTINGS* symSettings = new SYMBOL_EDITOR_SETTINGS(); + aProgram->GetSettingsManager().RegisterSettings( symSettings ); // manager takes ownership // We intentionally register KifaceSettings after SYMBOL_EDITOR_SETTINGS // In legacy configs, many settings were in a single editor config nd the migration routine @@ -392,7 +393,12 @@ bool IFACE::OnKifaceStart( PGM_BASE* aProgram, int aCtlBits, KIWAY* aKiway ) start_common( aCtlBits ); if( !loadGlobalLibTable() ) + { + // we didnt get anywhere deregister the settings + aProgram->GetSettingsManager().FlushAndRelease( symSettings, false ); + aProgram->GetSettingsManager().FlushAndRelease( KifaceSettings(), false ); return false; + } m_jobHandler = std::make_unique( aKiway ); diff --git a/pcbnew/pcbnew.cpp b/pcbnew/pcbnew.cpp index ad23ebeafe..44f3943e87 100644 --- a/pcbnew/pcbnew.cpp +++ b/pcbnew/pcbnew.cpp @@ -414,7 +414,21 @@ bool IFACE::OnKifaceStart( PGM_BASE* aProgram, int aCtlBits, KIWAY* aKiway ) start_common( aCtlBits ); if( !loadGlobalLibTable() ) + { + // we didnt get anywhere deregister the + aProgram->GetSettingsManager().FlushAndRelease( + aProgram->GetSettingsManager().GetAppSettings(), false ); + + aProgram->GetSettingsManager().FlushAndRelease( KifaceSettings(), false ); + + aProgram->GetSettingsManager().FlushAndRelease( + aProgram->GetSettingsManager().GetAppSettings(), false ); + + aProgram->GetSettingsManager().FlushAndRelease( + aProgram->GetSettingsManager().GetAppSettings(), false ); + return false; + } m_jobHandler = std::make_unique( aKiway );