SCH_SHEET::SearchHierarchy(): fix an issue when comparing file names.
We are using the unix separator in filenames in all platforms. However on Windows some filenames can contain native separators. We now ensure all filenames use the unix separator before comparison. Fix #6742
This commit is contained in:
parent
9fbceaa458
commit
3d57de91e8
|
@ -599,6 +599,11 @@ bool SCH_SHEET::SearchHierarchy( const wxString& aFilename, SCH_SCREEN** aScreen
|
|||
SCH_SHEET* sheet = nullptr;
|
||||
SCH_SCREEN* screen = nullptr;
|
||||
|
||||
// Ensure separators used in all filenames use the same symbol. We use the unix separator
|
||||
// in sch files, but if the filename is entered by a dialog on Windows the separator can differ
|
||||
wxString filename = aFilename;
|
||||
filename.Replace( '\\', '/' );
|
||||
|
||||
if( m_screen )
|
||||
{
|
||||
// Only check the root sheet once and don't recurse.
|
||||
|
@ -607,10 +612,16 @@ bool SCH_SHEET::SearchHierarchy( const wxString& aFilename, SCH_SCREEN** aScreen
|
|||
sheet = this;
|
||||
screen = m_screen;
|
||||
|
||||
if( screen && screen->GetFileName().Cmp( aFilename ) == 0 )
|
||||
if( screen )
|
||||
{
|
||||
*aScreen = screen;
|
||||
return true;
|
||||
wxString curr_fn = screen->GetFileName();
|
||||
curr_fn.Replace( '\\', '/' ); // use unix separator
|
||||
|
||||
if( curr_fn.Cmp( filename ) == 0 )
|
||||
{
|
||||
*aScreen = screen;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -625,10 +636,16 @@ bool SCH_SHEET::SearchHierarchy( const wxString& aFilename, SCH_SCREEN** aScreen
|
|||
sheet = static_cast< SCH_SHEET* >( item );
|
||||
screen = sheet->m_screen;
|
||||
|
||||
if( screen && screen->GetFileName().Cmp( aFilename ) == 0 )
|
||||
{
|
||||
*aScreen = sheet->m_screen;
|
||||
return true;
|
||||
if( screen )
|
||||
{
|
||||
wxString curr_fn = screen->GetFileName();
|
||||
curr_fn.Replace( '\\', '/' ); // use unix separator
|
||||
|
||||
if( curr_fn.Cmp( filename ) == 0 )
|
||||
{
|
||||
*aScreen = sheet->m_screen;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if( sheet->SearchHierarchy( aFilename, aScreen ) )
|
||||
|
|
Loading…
Reference in New Issue