Eeschema: fix an issue in netlists when using "<root sheet>" as root sheet path name.

Netlists do not accept any char in netnames (especially spice).
They must use only "/" as root sheet path name.

Especially _( "<root sheet>" ) breaks netlists because:
- there is a space in name, and special chars (< and >)
- it is a translatable name. so the actual name cannot be managed.
- most of netlist code in Kicad expects a "/" as root path.
This commit is contained in:
jean-pierre charras 2019-06-23 19:37:21 +02:00
parent 251e0ca19c
commit 710a82bc51
4 changed files with 20 additions and 3 deletions

View File

@ -72,6 +72,7 @@ void NETLIST_EXPORTER_PSPICE::ReplaceForbiddenChars( wxString &aNetName )
aNetName.Replace( "(", "_" );
aNetName.Replace( ")", "_" );
aNetName.Replace( " ", "_" );
}

View File

@ -602,8 +602,8 @@ wxString SCH_EDIT_FRAME::GetUniqueFilenameForCurrentSheet()
wxString filename = fn.GetName();
wxString sheetFullName = g_CurrentSheet->PathHumanReadable();
if( sheetFullName == "<root sheet>" || sheetFullName == _( "<root sheet>" ) ||
sheetFullName == "/" )
if( sheetFullName == SCH_SHEET_PATH::GetRootPathName( false ) ||
sheetFullName == SCH_SHEET_PATH::GetRootPathName( true ) )
{
// For the root sheet, use root schematic file name.
sheetFullName.clear();

View File

@ -166,12 +166,22 @@ wxString SCH_SHEET_PATH::Path() const
}
wxString SCH_SHEET_PATH::GetRootPathName( bool aUseShortName )
{
// return a PathName for the root sheet (like "/" or "<root>"
// DO NOT use it in netlists, because it can easily break these netlists
// especially after translation, because many netlists (i.e. spice) do not accept any char
// Use only the short name ("/") and the full name only in messages
return aUseShortName ? wxT( "/" ) : _( "<root_sheet>" );
}
wxString SCH_SHEET_PATH::PathHumanReadable() const
{
wxString s;
if( size() == 1 )
return _( "<root sheet>" );
return GetRootPathName( true ); // Use only the short name in netlists
s = wxT( "/" );

View File

@ -229,6 +229,12 @@ public:
*/
wxString PathHumanReadable() const;
/**
* @return a PathName for the root sheet (like "/" or "<root>"
* @param aUseShortName: true to return "/", false to return a longer name
*/
static wxString GetRootPathName( bool aUseShortName = true );
/**
* Function UpdateAllScreenReferences
* updates the reference and the m_Multi parameter (part selection) for all