Handle locally-coded file names for sheets

Windows can accidentally create forward slash-coded files.  This simply
converts them to the proper unix-coded value when set

Fixes https://gitlab.com/kicad/code/kicad/issues/10964
This commit is contained in:
Seth Hillbrand 2022-03-01 17:19:58 -08:00
parent 8385ce3021
commit 429544c188
2 changed files with 23 additions and 17 deletions

View File

@ -317,6 +317,28 @@ void SCH_SHEET::SwapData( SCH_ITEM* aItem )
}
void SCH_SHEET::SetFields( const std::vector<SCH_FIELD>& aFields )
{
m_fields = aFields;
int next_id = SHEET_MANDATORY_FIELDS;
for( int ii = 0; ii < int( m_fields.size() ); )
{
if( m_fields[ii].GetId() < 0 || m_fields[ii].GetId() >= ssize_t( m_fields.size() ) )
m_fields[ii].SetId( next_id++ );
if( m_fields[ii].GetId() != ii )
std::swap( m_fields[ii], m_fields[m_fields[ii].GetId()]);
if( m_fields[ii].GetId() == ii )
++ii;
}
// Make sure that we get the UNIX variant of the file path
SetFileName( m_fields[SHEETFILENAME].GetText() );
}
void SCH_SHEET::AddPin( SCH_SHEET_PIN* aSheetPin )
{
wxASSERT( aSheetPin != nullptr );

View File

@ -95,23 +95,7 @@ public:
*
* @param aFields are the fields to set in this symbol.
*/
void SetFields( const std::vector<SCH_FIELD>& aFields )
{
m_fields = aFields;
int next_id = SHEET_MANDATORY_FIELDS;
for( int ii = 0; ii < int( m_fields.size() ); )
{
if( m_fields[ii].GetId() < 0 || m_fields[ii].GetId() >= ssize_t( m_fields.size() ) )
m_fields[ii].SetId( next_id++ );
if( m_fields[ii].GetId() != ii )
std::swap( m_fields[ii], m_fields[m_fields[ii].GetId()]);
if( m_fields[ii].GetId() == ii )
++ii;
}
}
void SetFields( const std::vector<SCH_FIELD>& aFields );
wxString GetName() const { return m_fields[ SHEETNAME ].GetText(); }