Fix crash if we exit lib table setup

Fixes https://gitlab.com/kicad/code/kicad/-/issues/16917
This commit is contained in:
Marek Roszko 2024-02-11 21:04:09 -05:00
parent d694bb5960
commit 6a37f99e94
3 changed files with 24 additions and 1 deletions

View File

@ -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() );

View File

@ -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<EESCHEMA_JOBS_HANDLER>( aKiway );

View File

@ -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<CVPCB_SETTINGS>(), false );
aProgram->GetSettingsManager().FlushAndRelease( KifaceSettings(), false );
aProgram->GetSettingsManager().FlushAndRelease(
aProgram->GetSettingsManager().GetAppSettings<FOOTPRINT_EDITOR_SETTINGS>(), false );
aProgram->GetSettingsManager().FlushAndRelease(
aProgram->GetSettingsManager().GetAppSettings<EDA_3D_VIEWER_SETTINGS>(), false );
return false;
}
m_jobHandler = std::make_unique<PCBNEW_JOBS_HANDLER>( aKiway );