From 2a769dc0b0d6ce34c90faa2d187fde080e884338 Mon Sep 17 00:00:00 2001 From: Wayne Stambaugh Date: Tue, 13 Aug 2019 16:33:57 -0400 Subject: [PATCH] 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 0328f3e33bf3c5400dc2e3f1512d7ca7a86a0acb) --- eeschema/sheet.cpp | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/eeschema/sheet.cpp b/eeschema/sheet.cpp index 12a6d5589b..5d41a9a837 100644 --- a/eeschema/sheet.cpp +++ b/eeschema/sheet.cpp @@ -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() );