Simplify eeschema's plot filename algorithm.
We have different requirements than sheet paths for netlists, so going through that code and then doing a lot of conversions just ends up with a mess. We now generate the path directly from the SCH_SHEET_PATH. Fixes: lp:1852353 * https://bugs.launchpad.net/kicad/+bug/1852353
This commit is contained in:
parent
8ce04d3362
commit
7a8f2a5623
|
@ -577,41 +577,15 @@ void SCH_EDIT_FRAME::OnCloseWindow( wxCloseEvent& aEvent )
|
||||||
|
|
||||||
wxString SCH_EDIT_FRAME::GetUniqueFilenameForCurrentSheet()
|
wxString SCH_EDIT_FRAME::GetUniqueFilenameForCurrentSheet()
|
||||||
{
|
{
|
||||||
wxFileName fn = GetScreen()->GetFileName();
|
// Filename is rootSheetName-sheetName-...-sheetName
|
||||||
|
// Note that we need to fetch the rootSheetName out of its filename, as the root SCH_SHEET's
|
||||||
|
// name is just a timestamp.
|
||||||
|
|
||||||
// Name is <root sheet filename>-<sheet path> and has no extension.
|
wxFileName rootFn( g_CurrentSheet->at( 0 )->GetFileName() );
|
||||||
// However if filename is too long name is <sheet filename>-<sheet number>
|
wxString filename = rootFn.GetName();
|
||||||
|
|
||||||
#define FN_LEN_MAX 80 // A reasonable value for the short filename len
|
for( unsigned i = 1; i < g_CurrentSheet->size(); i++ )
|
||||||
|
filename += wxT( "-" ) + g_CurrentSheet->at( i )->GetName();
|
||||||
wxString filename = fn.GetName();
|
|
||||||
wxString sheetFullName = g_CurrentSheet->PathHumanReadable();
|
|
||||||
|
|
||||||
if( sheetFullName == SCH_SHEET_PATH::GetRootPathName( false ) ||
|
|
||||||
sheetFullName == SCH_SHEET_PATH::GetRootPathName( true ) )
|
|
||||||
{
|
|
||||||
// For the root sheet, use root schematic file name.
|
|
||||||
sheetFullName.clear();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if( filename.Last() != '-' || filename.Last() != '_' )
|
|
||||||
filename += '-';
|
|
||||||
|
|
||||||
// Remove the first and last '/' of the path human readable
|
|
||||||
sheetFullName.RemoveLast();
|
|
||||||
sheetFullName.Remove( 0, 1 );
|
|
||||||
sheetFullName.Trim( true );
|
|
||||||
sheetFullName.Trim( false );
|
|
||||||
|
|
||||||
// Convert path human readable separator to '-'
|
|
||||||
sheetFullName.Replace( "/", "-" );
|
|
||||||
}
|
|
||||||
|
|
||||||
if( ( filename.Len() + sheetFullName.Len() ) < FN_LEN_MAX )
|
|
||||||
filename += sheetFullName;
|
|
||||||
else
|
|
||||||
filename << wxT( "-" ) << GetScreen()->m_ScreenNumber;
|
|
||||||
|
|
||||||
return filename;
|
return filename;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue