From 64d6c3f91c8574ae469386ef3f13a4ed3cc45051 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Mon, 27 Feb 2017 17:22:06 +0100 Subject: [PATCH] eeschema segfault when a library "T" command is missing Halign Valign values Fixes: lp:1668082 https://bugs.launchpad.net/kicad/+bug/1668082 --- eeschema/sch_legacy_plugin.cpp | 60 ++++++++++++++++++---------------- 1 file changed, 32 insertions(+), 28 deletions(-) diff --git a/eeschema/sch_legacy_plugin.cpp b/eeschema/sch_legacy_plugin.cpp index d94de18ccc..9a29bad471 100644 --- a/eeschema/sch_legacy_plugin.cpp +++ b/eeschema/sch_legacy_plugin.cpp @@ -2905,42 +2905,46 @@ LIB_TEXT* SCH_LEGACY_PLUGIN_CACHE::loadText( std::unique_ptr< LIB_PART >& aPart, if( parseInt( aReader, line, &line ) > 0 ) text->SetBold( true ); - switch( parseChar( aReader, line, &line ) ) + // Some old libaries version > 2.0 do not have these options for text justification: + if( !is_eol( *line ) ) { - case 'L': - text->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); - break; + switch( parseChar( aReader, line, &line ) ) + { + case 'L': + text->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT ); + break; - case 'C': - text->SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER ); - break; + case 'C': + text->SetHorizJustify( GR_TEXT_HJUSTIFY_CENTER ); + break; - case 'R': - text->SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT ); - break; + case 'R': + text->SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT ); + break; - default: - SCH_PARSE_ERROR( _( "invalid horizontal text justication parameter, expected L, C, or R" ), - aReader, line ); - } + default: + SCH_PARSE_ERROR( _( "invalid horizontal text justication parameter, expected L, C, or R" ), + aReader, line ); + } - switch( parseChar( aReader, line, &line ) ) - { - case 'T': - text->SetVertJustify( GR_TEXT_VJUSTIFY_TOP ); - break; + switch( parseChar( aReader, line, &line ) ) + { + case 'T': + text->SetVertJustify( GR_TEXT_VJUSTIFY_TOP ); + break; - case 'C': - text->SetVertJustify( GR_TEXT_VJUSTIFY_CENTER ); - break; + case 'C': + text->SetVertJustify( GR_TEXT_VJUSTIFY_CENTER ); + break; - case 'B': - text->SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM ); - break; + case 'B': + text->SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM ); + break; - default: - SCH_PARSE_ERROR( _( "invalid vertical text justication parameter, expected T, C, or B" ), - aReader, line ); + default: + SCH_PARSE_ERROR( _( "invalid vertical text justication parameter, expected T, C, or B" ), + aReader, line ); + } } }