Commit 6ebc2a52 authored by charras's avatar charras

fixed problems in relative paths calculations for libs and docs files

parent 51efe030
......@@ -1013,27 +1013,22 @@ wxString WinEDA_App::ReturnFilenameWithRelativePathInLibPath( const wxString& aF
*/
wxFileName fn = aFullFilename;
wxString filename = aFullFilename;
int pathlen = -1; // path len, used to find the better subpath within defualts paths
unsigned pathlen = fn.GetPath().Len(); /* path len, used to find the better (shortest) subpath
* within defaults paths */
if( m_libSearchPaths.Index( fn.GetPath() ) != wxNOT_FOUND ) // Ok, trivial case
filename = fn.GetName();
else // not in the default, : see if this file is in a subpath:
{
filename = fn.GetPathWithSep() + fn.GetFullName();
for( unsigned kk = 0; kk < m_libSearchPaths.GetCount(); kk++ )
{
fn = aFullFilename;
// Search for the shortest subpath within m_libSearchPaths:
if( fn.MakeRelativeTo( m_libSearchPaths[kk] ) )
{
if( fn.GetPathWithSep().StartsWith( wxT("..") ) ) // Path outside kicad libs paths
continue;
if( pathlen < 0 // a first subpath is found
|| pathlen > (int) fn.GetPath().Len() ) // or a better subpath if found
if( pathlen > fn.GetPath().Len() ) // A better (shortest) subpath is found
{
filename = fn.GetPathWithSep() + fn.GetFullName();
pathlen = fn.GetPath().Len();
}
fn = aFullFilename; //Try to find a better subpath
}
}
}
......
......@@ -182,12 +182,14 @@ void DIALOG_MODULE_BOARD_EDITOR::InitModeditProperties()
S3D_MASTER* draw3D = m_CurrentModule->m_3D_Drawings;
while( draw3D )
{
if( !draw3D->m_Shape3DName.IsEmpty() )
{
S3D_MASTER* draw3DCopy = new S3D_MASTER(NULL);
draw3DCopy->Copy( draw3D );
m_Shapes3D_list.push_back( draw3DCopy );
m_3D_ShapeNameListBox->Append(draw3DCopy->m_Shape3DName);
}
draw3D = (S3D_MASTER*) draw3D->Next();
}
......
......@@ -46,9 +46,9 @@ DIALOG_MODULE_MODULE_EDITOR::~DIALOG_MODULE_MODULE_EDITOR()
}
/***************************************/
/********************************************************/
void DIALOG_MODULE_MODULE_EDITOR::InitModeditProperties()
/***************************************/
/********************************************************/
{
SetFocus();
......@@ -58,12 +58,14 @@ void DIALOG_MODULE_MODULE_EDITOR::InitModeditProperties()
S3D_MASTER* draw3D = m_CurrentModule->m_3D_Drawings;
while( draw3D )
{
if( !draw3D->m_Shape3DName.IsEmpty() )
{
S3D_MASTER* draw3DCopy = new S3D_MASTER(NULL);
draw3DCopy->Copy( draw3D );
m_Shapes3D_list.push_back( draw3DCopy );
m_3D_ShapeNameListBox->Append(draw3DCopy->m_Shape3DName);
}
draw3D = (S3D_MASTER*) draw3D->Next();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment