Capture exceptions thrown by FP_LIB_TABLE::FindRow() in some places.

FindRow() exception is unfortunately not captured in all places using it.
The result is the application closes.
This commit is contained in:
jean-pierre charras 2023-08-20 12:27:37 +02:00
parent ea3101587a
commit 1c11a2c7bd
2 changed files with 23 additions and 5 deletions

View File

@ -3,7 +3,7 @@
* *
* Copyright (C) 2010-2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com> * Copyright (C) 2010-2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2012 Wayne Stambaugh <stambaughw@gmail.com> * Copyright (C) 2012 Wayne Stambaugh <stambaughw@gmail.com>
* Copyright (C) 2012-2021 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 2012-2023 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -277,7 +277,16 @@ long long FP_LIB_TABLE::GenerateTimestamp( const wxString* aNickname )
for( const wxString& nickname : GetLogicalLibs() ) for( const wxString& nickname : GetLogicalLibs() )
{ {
const FP_LIB_TABLE_ROW* row = FindRow( nickname, true ); const FP_LIB_TABLE_ROW* row = nullptr;
try
{
row = FindRow( nickname, true );
}
catch( ... )
{
// Do nothing if not found: just skip.
}
wxCHECK2( row && row->plugin, continue ); wxCHECK2( row && row->plugin, continue );
@ -318,7 +327,6 @@ const FP_LIB_TABLE_ROW* FP_LIB_TABLE::FindRow( const wxString& aNickname, bool a
{ {
wxString msg = wxString::Format( _( "fp-lib-table files contain no library named '%s'." ), wxString msg = wxString::Format( _( "fp-lib-table files contain no library named '%s'." ),
aNickname ); aNickname );
THROW_IO_ERROR( msg ); THROW_IO_ERROR( msg );
} }

View File

@ -1,7 +1,7 @@
/* /*
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2018-2022 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 2018-2023 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software: you can redistribute it and/or modify it * This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the * under the terms of the GNU General Public License as published by the
@ -54,7 +54,17 @@ void FP_TREE_MODEL_ADAPTER::AddLibraries( EDA_BASE_FRAME* aParent )
for( const wxString& libName : m_libs->GetLogicalLibs() ) for( const wxString& libName : m_libs->GetLogicalLibs() )
{ {
const FP_LIB_TABLE_ROW* library = m_libs->FindRow( libName, true ); const FP_LIB_TABLE_ROW* library = nullptr;
try
{
library = m_libs->FindRow( libName, true );
}
catch( ... )
{
// Skip loading this library, if not exists/ not found
continue;
}
bool pinned = alg::contains( cfg->m_Session.pinned_fp_libs, libName ) bool pinned = alg::contains( cfg->m_Session.pinned_fp_libs, libName )
|| alg::contains( project.m_PinnedFootprintLibs, libName ); || alg::contains( project.m_PinnedFootprintLibs, libName );