Eeschema: fix bug in sheet name comparisons on Windows.

The use of wxPATH_UNIX when calling GetFullPath() on windows drops the
volume identifier (c:\) from the file name which will cause comparison
failures.

(cherry picked from commit 0328f3e33b)
This commit is contained in:
Wayne Stambaugh 2019-08-13 16:33:57 -04:00
parent 3475bfb2aa
commit 2a769dc0b0
1 changed files with 13 additions and 11 deletions

View File

@ -58,7 +58,7 @@ bool SCH_EDIT_FRAME::checkSheetForRecursion( SCH_SHEET* aSheet, SCH_SHEET_PATH*
// something is seriously broken.
wxASSERT( destFile.IsAbsolute() );
if( hierarchy.TestForRecursion( sheetHierarchy, destFile.GetFullPath( wxPATH_UNIX ) ) )
if( hierarchy.TestForRecursion( sheetHierarchy, destFile.GetFullPath() ) )
{
msg.Printf( _( "The sheet changes cannot be made because the destination sheet already "
"has the sheet \"%s\" or one of it's subsheets as a parent somewhere in "
@ -192,22 +192,19 @@ bool SCH_EDIT_FRAME::LoadSheetFromFile( SCH_SHEET* aSheet, SCH_SHEET_PATH* aHier
else if( rsp == wxID_NO )
{
topLevelSheetPath = fileName.GetPathWithSep();
if( wxFileName::GetPathSeparator() == '\\' )
topLevelSheetPath.Replace( "\\", "/" );
}
else
{
topLevelSheetPath = tmp.GetPathWithSep( wxPATH_UNIX );
topLevelSheetPath = tmp.GetPathWithSep();
}
}
else
{
topLevelSheetPath = tmp.GetPathWithSep();
if( wxFileName::GetPathSeparator() == '\\' )
topLevelSheetPath.Replace( "\\", "/" );
}
if( wxFileName::GetPathSeparator() == '\\' )
topLevelSheetPath.Replace( "\\", "/" );
}
// Make sure any new sheet changes do not cause any recursion issues.
@ -444,7 +441,7 @@ bool SCH_EDIT_FRAME::LoadSheetFromFile( SCH_SHEET* aSheet, SCH_SHEET_PATH* aHier
const SYMBOL_LIB_TABLE_ROW* row = table.FindRow( libName );
auto newRow = new SYMBOL_LIB_TABLE_ROW( libName, uri, row->GetType(),
row->GetOptions(), row->GetDescr() );
row->GetOptions(), row->GetDescr() );
Prj().SchSymbolLibTable()->InsertRow( newRow );
libTableChanged = true;
@ -709,7 +706,7 @@ bool SCH_EDIT_FRAME::EditSheet( SCH_SHEET* aSheet, SCH_SHEET_PATH* aHierarchy,
// Create a temporary sheet for recursion testing to prevent a possible recursion error.
std::unique_ptr< SCH_SHEET> tmpSheet( new SCH_SHEET );
tmpSheet->SetName( dlg.GetSheetName() );
tmpSheet->SetFileName( userFileName.GetFullPath( wxPATH_UNIX ) );
tmpSheet->SetFileName( userFileName.GetFullPath() );
tmpSheet->SetScreen( useScreen );
// No need to check for valid library IDs if we are using an existing screen.
@ -746,7 +743,12 @@ bool SCH_EDIT_FRAME::EditSheet( SCH_SHEET* aSheet, SCH_SHEET_PATH* aHierarchy,
aHierarchy->LastScreen()->Append( aSheet );
}
aSheet->SetFileName( userFileName.GetFullPath( wxPATH_UNIX ) );
wxString tmpFn = userFileName.GetFullPath();
if( wxFileName::GetPathSeparator() == '\\' )
tmpFn.Replace( "\\", "/" );
aSheet->SetFileName( tmpFn );
aSheet->SetFileNameSize( dlg.GetFileNameTextSize() );
aSheet->SetName( dlg.GetSheetName() );
aSheet->SetSheetNameSize( dlg.GetSheetNameTextSize() );