From 7a8f2a56233bdc8a8c7dc2c8281c1d237ede092c Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Wed, 13 Nov 2019 19:15:11 +0000 Subject: [PATCH] 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 --- eeschema/sch_edit_frame.cpp | 40 +++++++------------------------------ 1 file changed, 7 insertions(+), 33 deletions(-) diff --git a/eeschema/sch_edit_frame.cpp b/eeschema/sch_edit_frame.cpp index b525eabd43..403b34bd2e 100644 --- a/eeschema/sch_edit_frame.cpp +++ b/eeschema/sch_edit_frame.cpp @@ -577,41 +577,15 @@ void SCH_EDIT_FRAME::OnCloseWindow( wxCloseEvent& aEvent ) 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 - and has no extension. - // However if filename is too long name is - + wxFileName rootFn( g_CurrentSheet->at( 0 )->GetFileName() ); + wxString filename = rootFn.GetName(); - #define FN_LEN_MAX 80 // A reasonable value for the short filename len - - 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; + for( unsigned i = 1; i < g_CurrentSheet->size(); i++ ) + filename += wxT( "-" ) + g_CurrentSheet->at( i )->GetName(); return filename; }