fixed: incorrect sub path calculation for libs and doc filenames (full filenames where always converted to relative paths,

even when they are not in standard libraries paths)
This commit is contained in:
charras 2009-08-13 18:50:47 +00:00
parent 8aca4b3cb0
commit f9f671d1b9
1 changed files with 7 additions and 4 deletions

View File

@ -998,7 +998,7 @@ void WinEDA_App::SaveLastVisitedLibraryPath( const wxString& aPath )
/** ReturnFilenameWithRelativePathInLibPath /** ReturnFilenameWithRelativePathInLibPath
* @return a short filename (with extension) with only a relative path if this filename * @return a short filename (with extension) with only a relative path if this filename
* can be found in library paths * can be found in library paths (i.e. if the path is a sub path of a libraries path)
* @param aFullFilename = filename with path and extension. * @param aFullFilename = filename with path and extension.
*/ */
wxString WinEDA_App::ReturnFilenameWithRelativePathInLibPath( const wxString& aFullFilename ) wxString WinEDA_App::ReturnFilenameWithRelativePathInLibPath( const wxString& aFullFilename )
@ -1008,7 +1008,8 @@ wxString WinEDA_App::ReturnFilenameWithRelativePathInLibPath( const wxString& aF
* the library name with the full or relative path. * the library name with the full or relative path.
* the relative path, when possible is preferable, * the relative path, when possible is preferable,
* because it preserve use of default libraries paths, when the path is a sub path of these default paths * because it preserve use of default libraries paths, when the path is a sub path of these default paths
* * Note we accept only sub paths,
* not relative paths starting by ../ that are not subpaths and are outside kicad libs paths
*/ */
wxFileName fn = aFullFilename; wxFileName fn = aFullFilename;
wxString filename = aFullFilename; wxString filename = aFullFilename;
@ -1023,8 +1024,10 @@ wxString WinEDA_App::ReturnFilenameWithRelativePathInLibPath( const wxString& aF
{ {
if( fn.MakeRelativeTo( m_libSearchPaths[kk] ) ) if( fn.MakeRelativeTo( m_libSearchPaths[kk] ) )
{ {
if( pathlen < 0 // a subpath is found if( fn.GetPathWithSep().StartsWith( wxT("..") ) ) // Path outside kicad libs paths
|| pathlen > (int) fn.GetPath().Len() ) // a better subpath if found continue;
if( pathlen < 0 // a first subpath is found
|| pathlen > (int) fn.GetPath().Len() ) // or a better subpath if found
{ {
filename = fn.GetPathWithSep() + fn.GetFullName(); filename = fn.GetPathWithSep() + fn.GetFullName();
pathlen = fn.GetPath().Len(); pathlen = fn.GetPath().Len();