7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-20 21:31:42 +00:00

Don't write empty data tags

Also avoid throwing if a data stream is empty so that you can still read
the schematic/pcb/library

Fixes https://gitlab.com/kicad/code/kicad/-/issues/20301
This commit is contained in:
Seth Hillbrand 2025-03-11 09:42:06 -07:00
parent 31b788c04f
commit a6fbf4bbdb

View File

@ -162,6 +162,13 @@ void EMBEDDED_FILES::WriteEmbeddedFiles( OUTPUTFORMATTER& aOut, bool aWriteData
{
const EMBEDDED_FILE& file = *entry;
// Skip empty files
if( file.compressedEncodedData.empty() )
{
wxLogDebug( wxT( "Error: Embedded file '%s' is empty" ), file.name );
continue;
}
aOut.Print( "(file " );
aOut.Print( "(name %s)", aOut.Quotew( file.name ).c_str() );
@ -376,7 +383,21 @@ void EMBEDDED_FILES_PARSER::ParseEmbedded( EMBEDDED_FILES* aFiles )
break;
case T_data:
NeedBAR();
try
{
NeedBAR();
}
catch( const PARSE_ERROR& e )
{
// No data in the file -- due to bug in writer for 9.0.0
NeedRIGHT();
break;
}
catch( ... )
{
throw;
}
token = NextTok();
file->compressedEncodedData.reserve( 1 << 17 );