Correctly handle locked token for PCB_TEXTBOX and PCB_TABLECELL.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/17439
This commit is contained in:
Jeff Young 2024-03-15 21:41:32 +00:00
parent fc11862580
commit d17151ac1b
1 changed files with 40 additions and 37 deletions

View File

@ -3391,6 +3391,7 @@ void PCB_IO_KICAD_SEXPR_PARSER::parseTextBoxContent( PCB_TEXTBOX* aTextBox )
T token = NextTok(); T token = NextTok();
// Legacy locked
if( token == T_locked ) if( token == T_locked )
{ {
aTextBox->SetLocked( true ); aTextBox->SetLocked( true );
@ -3402,10 +3403,20 @@ void PCB_IO_KICAD_SEXPR_PARSER::parseTextBoxContent( PCB_TEXTBOX* aTextBox )
aTextBox->SetText( FromUTF8() ); aTextBox->SetText( FromUTF8() );
NeedLEFT(); for( token = NextTok(); token != T_RIGHT; token = NextTok() )
{
if( token != T_LEFT )
Expecting( T_LEFT );
token = NextTok(); token = NextTok();
if( token == T_start ) switch( token )
{
case T_locked:
aTextBox->SetLocked( parseMaybeAbsentBool( true ) );
break;
case T_start:
{ {
int x = parseBoardUnits( "X coordinate" ); int x = parseBoardUnits( "X coordinate" );
int y = parseBoardUnits( "Y coordinate" ); int y = parseBoardUnits( "Y coordinate" );
@ -3422,8 +3433,10 @@ void PCB_IO_KICAD_SEXPR_PARSER::parseTextBoxContent( PCB_TEXTBOX* aTextBox )
y = parseBoardUnits( "Y coordinate" ); y = parseBoardUnits( "Y coordinate" );
aTextBox->SetEnd( VECTOR2I( x, y ) ); aTextBox->SetEnd( VECTOR2I( x, y ) );
NeedRIGHT(); NeedRIGHT();
break;
} }
else if( token == T_pts )
case T_pts:
{ {
aTextBox->SetShape( SHAPE_T::POLY ); aTextBox->SetShape( SHAPE_T::POLY );
aTextBox->GetPolyShape().RemoveAllContours(); aTextBox->GetPolyShape().RemoveAllContours();
@ -3431,21 +3444,11 @@ void PCB_IO_KICAD_SEXPR_PARSER::parseTextBoxContent( PCB_TEXTBOX* aTextBox )
while( (token = NextTok() ) != T_RIGHT ) while( (token = NextTok() ) != T_RIGHT )
parseOutlinePoints( aTextBox->GetPolyShape().Outline( 0 ) ); parseOutlinePoints( aTextBox->GetPolyShape().Outline( 0 ) );
}
else NeedRIGHT();
{ break;
Expecting( "start or pts" );
} }
for( token = NextTok(); token != T_RIGHT; token = NextTok() )
{
if( token != T_LEFT )
Expecting( T_LEFT );
token = NextTok();
switch( token )
{
case T_angle: case T_angle:
// Set the angle of the text only, the coordinates of the box (a polygon) are // Set the angle of the text only, the coordinates of the box (a polygon) are
// already at the right position, and must not be rotated // already at the right position, and must not be rotated
@ -3514,9 +3517,9 @@ void PCB_IO_KICAD_SEXPR_PARSER::parseTextBoxContent( PCB_TEXTBOX* aTextBox )
default: default:
if( PCB_TABLECELL* cell = dynamic_cast<PCB_TABLECELL*>( aTextBox ) ) if( PCB_TABLECELL* cell = dynamic_cast<PCB_TABLECELL*>( aTextBox ) )
Expecting( "angle, width, layer, effects, span, render_cache, uuid or tstamp" ); Expecting( "locked, start, pts, angle, width, layer, effects, span, render_cache, uuid or tstamp" );
else else
Expecting( "angle, width, layer, effects, render_cache, uuid or tstamp" ); Expecting( "locked, start, pts, angle, width, layer, effects, render_cache, uuid or tstamp" );
} }
} }