Browse Source

Trim values before setting into fields grid.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/18474
pull/19/head
Jeff Young 4 days ago
parent
commit
2aac00f0ed
  1. 18
      eeschema/fields_grid_table.cpp
  2. 19
      pcbnew/pcb_fields_grid_table.cpp

18
eeschema/fields_grid_table.cpp

@ -885,11 +885,11 @@ void FIELDS_GRID_TABLE::SetValue( int aRow, int aCol, const wxString &aValue )
VECTOR2I pos;
wxString value = aValue;
switch( aCol )
if( aCol != FDC_VALUE )
value.Trim( true ).Trim( false );
if( aCol == FDC_TEXT_SIZE || aCol == FDC_POSX || aCol == FDC_POSY )
{
case FDC_TEXT_SIZE:
case FDC_POSX:
case FDC_POSY:
m_eval->SetDefaultUnits( m_frame->GetUserUnits() );
if( m_eval->Process( value ) )
@ -897,11 +897,6 @@ void FIELDS_GRID_TABLE::SetValue( int aRow, int aCol, const wxString &aValue )
m_evalOriginal[ { aRow, aCol } ] = value;
value = m_eval->Result();
}
break;
default:
break;
}
switch( aCol )
@ -911,7 +906,6 @@ void FIELDS_GRID_TABLE::SetValue( int aRow, int aCol, const wxString &aValue )
break;
case FDC_VALUE:
{
if( m_parentType == SCH_SHEET_T && field.GetId() == FIELD_T::SHEET_FILENAME )
{
value = EnsureFileExtension( value, FILEEXT::KiCadSchematicFileExtension );
@ -923,7 +917,6 @@ void FIELDS_GRID_TABLE::SetValue( int aRow, int aCol, const wxString &aValue )
field.SetText( UnescapeString( value ) );
break;
}
case FDC_SHOWN:
field.SetVisible( BoolFromString( value ) );
@ -986,8 +979,7 @@ void FIELDS_GRID_TABLE::SetValue( int aRow, int aCol, const wxString &aValue )
break;
case FDC_TEXT_SIZE:
field.SetTextSize( VECTOR2I( m_frame->ValueFromString( value ),
m_frame->ValueFromString( value ) ) );
field.SetTextSize( VECTOR2I( m_frame->ValueFromString( value ), m_frame->ValueFromString( value ) ) );
break;
case FDC_ORIENTATION:

19
pcbnew/pcb_fields_grid_table.cpp

@ -345,13 +345,15 @@ void PCB_FIELDS_GRID_TABLE::SetValue( int aRow, int aCol, const wxString &aValue
VECTOR2I pos;
wxString value = aValue;
switch( aCol )
if( aCol != PFC_VALUE )
value.Trim( true ).Trim( false );
if( aCol == PFC_WIDTH
|| aCol == PFC_HEIGHT
|| aCol == PFC_THICKNESS
|| aCol == PFC_XOFFSET
|| aCol == PFC_YOFFSET )
{
case PFC_WIDTH:
case PFC_HEIGHT:
case PFC_THICKNESS:
case PFC_XOFFSET:
case PFC_YOFFSET:
m_eval->SetDefaultUnits( m_frame->GetUserUnits() );
if( m_eval->Process( value ) )
@ -359,11 +361,6 @@ void PCB_FIELDS_GRID_TABLE::SetValue( int aRow, int aCol, const wxString &aValue
m_evalOriginal[ { aRow, aCol } ] = value;
value = m_eval->Result();
}
break;
default:
break;
}
switch( aCol )

Loading…
Cancel
Save