From 03423f13a1886a97a06e61b79d4c565b6faf5725 Mon Sep 17 00:00:00 2001 From: Wayne Stambaugh Date: Thu, 3 Sep 2020 11:10:47 -0400 Subject: [PATCH] Eeschema: fix broken new sheet path comparison on windows. Using wxFileName::GetPath( wxPATH_WITH_SEPARATOR ) does not include the drive specifier (A:, B:, C:, etc.) on windows which fails the comparison with the project path 100% of the time. wxFileName::GetPathWithSep() solves the issue nicely. Fixes https://gitlab.com/kicad/code/kicad/issues/5077 --- eeschema/sheet.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/eeschema/sheet.cpp b/eeschema/sheet.cpp index a52f5fcb81..47f0faba7e 100644 --- a/eeschema/sheet.cpp +++ b/eeschema/sheet.cpp @@ -171,8 +171,7 @@ bool SCH_EDIT_FRAME::LoadSheetFromFile( SCH_SHEET* aSheet, SCH_SHEET_PATH* aHier // If the loaded schematic is in a different folder from the current project and // it contains hierarchical sheets, the hierarchical sheet paths need to be updated. - if( fileName.GetPath( wxPATH_GET_SEPARATOR ) != Prj().GetProjectPath() - && newSheet->CountSheets() ) + if( fileName.GetPathWithSep() != Prj().GetProjectPath() && newSheet->CountSheets() ) { // Give the user the option to choose relative path if possible. if( tmp.MakeRelativeTo( Prj().GetProjectPath() ) ) @@ -204,7 +203,7 @@ bool SCH_EDIT_FRAME::LoadSheetFromFile( SCH_SHEET* aSheet, SCH_SHEET_PATH* aHier wxMessageDialog::ButtonLabel okButtonLabel( _( "Continue Load" ) ); wxMessageDialog::ButtonLabel cancelButtonLabel( _( "Cancel Load" ) ); - if( fileName.GetPath( wxPATH_GET_SEPARATOR ) == Prj().GetProjectPath() + if( fileName.GetPathWithSep() == Prj().GetProjectPath() && !prjScreens.HasSchematic( fullFilename ) ) { // A schematic in the current project path that isn't part of the current project. @@ -231,7 +230,7 @@ bool SCH_EDIT_FRAME::LoadSheetFromFile( SCH_SHEET* aSheet, SCH_SHEET_PATH* aHier return false; } } - else if( fileName.GetPath( wxPATH_GET_SEPARATOR ) != Prj().GetProjectPath() ) + else if( fileName.GetPathWithSep() != Prj().GetProjectPath() ) { // A schematic loaded from a path other than the current project path.