Fix hierarchical schematic file sheet path bug.
Sheet file name paths were not being saved and restored properly under certain conditions when walking the sheet hierarchy causing schematic load errors. Changed debugging output to use wxLogTrace left over from last fix. Fixes lp:1748401 https://bugs.launchpad.net/kicad/+bug/1748401
This commit is contained in:
parent
fd0b364b91
commit
b8c00a0d07
|
@ -600,7 +600,8 @@ SCH_SHEET* SCH_LEGACY_PLUGIN::Load( const wxString& aFileName, KIWAY* aKiway,
|
||||||
|
|
||||||
if( aAppendToMe )
|
if( aAppendToMe )
|
||||||
{
|
{
|
||||||
wxLogDebug( "Append \"%s\" to sheet \"%s\".", aFileName, aAppendToMe->GetFileName() );
|
wxLogTrace( traceSchLegacyPlugin, "Append \"%s\" to sheet \"%s\".",
|
||||||
|
aFileName, aAppendToMe->GetFileName() );
|
||||||
|
|
||||||
wxFileName normedFn = aAppendToMe->GetFileName();
|
wxFileName normedFn = aAppendToMe->GetFileName();
|
||||||
|
|
||||||
|
@ -609,6 +610,8 @@ SCH_SHEET* SCH_LEGACY_PLUGIN::Load( const wxString& aFileName, KIWAY* aKiway,
|
||||||
if( aFileName.Right( normedFn.GetFullPath().Length() ) == normedFn.GetFullPath() )
|
if( aFileName.Right( normedFn.GetFullPath().Length() ) == normedFn.GetFullPath() )
|
||||||
m_path = aFileName.Left( aFileName.Length() - normedFn.GetFullPath().Length() );
|
m_path = aFileName.Left( aFileName.Length() - normedFn.GetFullPath().Length() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wxLogTrace( traceSchLegacyPlugin, "Normalized append path \"%s\".", m_path );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -652,16 +655,20 @@ void SCH_LEGACY_PLUGIN::loadHierarchy( SCH_SHEET* aSheet )
|
||||||
// stores the file name and extension. Add the project path to the file name and
|
// stores the file name and extension. Add the project path to the file name and
|
||||||
// extension to compare when calling SCH_SHEET::SearchHierarchy().
|
// extension to compare when calling SCH_SHEET::SearchHierarchy().
|
||||||
wxFileName fileName = aSheet->GetFileName();
|
wxFileName fileName = aSheet->GetFileName();
|
||||||
|
size_t dirCount = 0;
|
||||||
|
|
||||||
if( !fileName.IsAbsolute() )
|
if( !fileName.IsAbsolute() )
|
||||||
|
{
|
||||||
|
dirCount = fileName.GetDirCount();
|
||||||
fileName.MakeAbsolute( m_path );
|
fileName.MakeAbsolute( m_path );
|
||||||
|
}
|
||||||
|
|
||||||
// Save the current path so that it gets restored when decending and ascending the
|
// Save the current path so that it gets restored when decending and ascending the
|
||||||
// sheet hierarchy which allows for sheet schematic files to be nested in folders
|
// sheet hierarchy which allows for sheet schematic files to be nested in folders
|
||||||
// relative to the last path a schematic was loaded from.
|
// relative to the last path a schematic was loaded from.
|
||||||
m_path = fileName.GetPath();
|
m_path = fileName.GetPath();
|
||||||
|
|
||||||
wxLogDebug( "Saving last path \"%s\"", m_path );
|
wxLogTrace( traceSchLegacyPlugin, "Saving last path \"%s\"", m_path );
|
||||||
|
|
||||||
m_rootSheet->SearchHierarchy( fileName.GetFullPath(), &screen );
|
m_rootSheet->SearchHierarchy( fileName.GetFullPath(), &screen );
|
||||||
|
|
||||||
|
@ -716,7 +723,14 @@ void SCH_LEGACY_PLUGIN::loadHierarchy( SCH_SHEET* aSheet )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
wxLogDebug( "Restoring last path \"%s\"", fileName.GetPath() );
|
// Back out any relative paths so the last sheet file path is correct.
|
||||||
|
while( dirCount )
|
||||||
|
{
|
||||||
|
fileName.RemoveLastDir();
|
||||||
|
dirCount--;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxLogTrace( traceSchLegacyPlugin, "Restoring last path \"%s\"", fileName.GetPath() );
|
||||||
m_path = fileName.GetPath();
|
m_path = fileName.GetPath();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue