3D viewer: catch an exception thrown when a fp library is not found in table,

when the 3D viewer try to rebuild the 3D shape of a footprint.
Fixes #12524
https://gitlab.com/kicad/code/kicad/issues/12524
This commit is contained in:
jean-pierre charras 2022-09-27 18:32:48 +02:00
parent dc07ab9df1
commit 5b8cf96736
3 changed files with 28 additions and 12 deletions

View File

@ -2,7 +2,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) 2015-2016 Mario Luzeiro <mrluzeiro@ua.pt> * Copyright (C) 2015-2016 Mario Luzeiro <mrluzeiro@ua.pt>
* Copyright (C) 2015-2020 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 2015-2022 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
@ -928,12 +928,20 @@ void RENDER_3D_OPENGL::load3dModels( REPORTER* aStatusReporter )
if( m_boardAdapter.GetBoard()->GetProject() ) if( m_boardAdapter.GetBoard()->GetProject() )
{ {
const FP_LIB_TABLE_ROW* fpRow = try
m_boardAdapter.GetBoard()->GetProject()->PcbFootprintLibs()->FindRow( {
libraryName, false ); // FindRow() can throw an exception
const FP_LIB_TABLE_ROW* fpRow =
m_boardAdapter.GetBoard()->GetProject()->PcbFootprintLibs()->FindRow(
libraryName, false );
if( fpRow ) if( fpRow )
footprintBasePath = fpRow->GetFullURI( true ); footprintBasePath = fpRow->GetFullURI( true );
}
catch( ... )
{
// Do nothing if the libraryName is not found in lib table
}
} }
for( const FP_3DMODEL& fp_model : footprint->Models() ) for( const FP_3DMODEL& fp_model : footprint->Models() )

View File

@ -1258,12 +1258,20 @@ void RENDER_3D_RAYTRACE::load3DModels( CONTAINER_3D& aDstContainer, bool aSkipMa
wxString footprintBasePath = wxEmptyString; wxString footprintBasePath = wxEmptyString;
if( m_boardAdapter.GetBoard()->GetProject() ) if( m_boardAdapter.GetBoard()->GetProject() )
{ {
const FP_LIB_TABLE_ROW* fpRow = try
m_boardAdapter.GetBoard()->GetProject()->PcbFootprintLibs()->FindRow( {
libraryName, false ); // FindRow() can throw an exception
const FP_LIB_TABLE_ROW* fpRow =
m_boardAdapter.GetBoard()->GetProject()->PcbFootprintLibs()->FindRow(
libraryName, false );
if( fpRow ) if( fpRow )
footprintBasePath = fpRow->GetFullURI( true ); footprintBasePath = fpRow->GetFullURI( true );
}
catch( ... )
{
// Do nothing if the libraryName is not found in lib table
}
} }
while( sM != eM ) while( sM != eM )

View File

@ -219,7 +219,7 @@ TOOL_ACTION EDA_3D_ACTIONS::showSMD( "3DViewer.Control.attributesSMD",
TOOL_ACTION EDA_3D_ACTIONS::showVirtual( "3DViewer.Control.attributesOther", TOOL_ACTION EDA_3D_ACTIONS::showVirtual( "3DViewer.Control.attributesOther",
AS_ACTIVE, AS_ACTIVE,
'V', "", 'V', "",
_( "Toggle Other 3D models" ), _( "Toggle 3D models for 'Other' type components" ), _( "Toggle unspecified 3D models" ), _( "Toggle 3D models for 'unspecified' type components" ),
BITMAPS::show_other, AF_NONE ); BITMAPS::show_other, AF_NONE );
TOOL_ACTION EDA_3D_ACTIONS::showNotInPosFile( "3DViewer.Control.attribute_not_in_posfile", TOOL_ACTION EDA_3D_ACTIONS::showNotInPosFile( "3DViewer.Control.attribute_not_in_posfile",