From 566fefafc5aa43ad8c0e4057c0d07922bb83b65b Mon Sep 17 00:00:00 2001 From: Wayne Stambaugh Date: Sat, 22 Jun 2024 12:22:03 -0400 Subject: [PATCH] Fix Eagle schematic importer incorrect symbol value field and visibility. Also fix a crash if an XML_PARSER_ERROR exception is thrown when importing Eagle symbol libraries. Fixes https://gitlab.com/kicad/code/kicad/-/issues/18232 --- eeschema/sch_io/eagle/sch_io_eagle.cpp | 9 +++------ eeschema/symbol_editor/symbol_editor_import_export.cpp | 9 ++++++++- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/eeschema/sch_io/eagle/sch_io_eagle.cpp b/eeschema/sch_io/eagle/sch_io_eagle.cpp index d25177edda..7f30bbdf08 100644 --- a/eeschema/sch_io/eagle/sch_io_eagle.cpp +++ b/eeschema/sch_io/eagle/sch_io_eagle.cpp @@ -1842,7 +1842,7 @@ void SCH_IO_EAGLE::loadInstance( wxXmlNode* aInstanceNode ) valueField->SetVisible( part->GetFieldById( VALUE_FIELD )->IsVisible() ); - if( !userValue && epart->value ) + if( epart->value ) { valueField->SetText( *epart->value ); } @@ -1954,11 +1954,8 @@ void SCH_IO_EAGLE::loadInstance( wxXmlNode* aInstanceNode ) // Use the instance attribute to determine the reference and value field visibility. if( einstance.smashed && einstance.smashed.Get() ) { - if( !valueAttributeFound ) - symbol->GetField( VALUE_FIELD )->SetVisible( false ); - - if( !nameAttributeFound ) - symbol->GetField( REFERENCE_FIELD )->SetVisible( false ); + symbol->GetField( VALUE_FIELD )->SetVisible( valueAttributeFound ); + symbol->GetField( REFERENCE_FIELD )->SetVisible( nameAttributeFound ); } symbol->AddHierarchicalReference( m_sheetPath.Path(), reference, unit ); diff --git a/eeschema/symbol_editor/symbol_editor_import_export.cpp b/eeschema/symbol_editor/symbol_editor_import_export.cpp index ce3095d5ff..08f6fa8dd9 100644 --- a/eeschema/symbol_editor/symbol_editor_import_export.cpp +++ b/eeschema/symbol_editor/symbol_editor_import_export.cpp @@ -3,7 +3,7 @@ * * Copyright (C) 2016 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2008 Wayne Stambaugh - * Copyright (C) 2004-2023 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2004-2023, 2024 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -33,6 +33,7 @@ #include #include #include +#include void SYMBOL_EDIT_FRAME::ImportSymbol() @@ -108,6 +109,12 @@ void SYMBOL_EDIT_FRAME::ImportSymbol() DisplayErrorMessage( this, msg, ioe.What() ); return; } + catch( const XML_PARSER_ERROR& ioe ) + { + msg.Printf( _( "Cannot import symbol library '%s'." ), fn.GetFullPath() ); + DisplayErrorMessage( this, msg, ioe.what() ); + return; + } if( symbols.empty() ) {