Commit 6ebc2a52 authored by charras's avatar charras

fixed problems in relative paths calculations for libs and docs files

parent 51efe030
...@@ -1013,26 +1013,21 @@ wxString WinEDA_App::ReturnFilenameWithRelativePathInLibPath( const wxString& aF ...@@ -1013,26 +1013,21 @@ wxString WinEDA_App::ReturnFilenameWithRelativePathInLibPath( const wxString& aF
*/ */
wxFileName fn = aFullFilename; wxFileName fn = aFullFilename;
wxString filename = 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 for( unsigned kk = 0; kk < m_libSearchPaths.GetCount(); kk++ )
filename = fn.GetName();
else // not in the default, : see if this file is in a subpath:
{ {
filename = fn.GetPathWithSep() + fn.GetFullName(); fn = aFullFilename;
for( unsigned kk = 0; kk < m_libSearchPaths.GetCount(); kk++ ) // Search for the shortest subpath within m_libSearchPaths:
if( fn.MakeRelativeTo( m_libSearchPaths[kk] ) )
{ {
if( fn.MakeRelativeTo( m_libSearchPaths[kk] ) ) if( fn.GetPathWithSep().StartsWith( wxT("..") ) ) // Path outside kicad libs paths
continue;
if( pathlen > fn.GetPath().Len() ) // A better (shortest) subpath is found
{ {
if( fn.GetPathWithSep().StartsWith( wxT("..") ) ) // Path outside kicad libs paths filename = fn.GetPathWithSep() + fn.GetFullName();
continue; pathlen = fn.GetPath().Len();
if( pathlen < 0 // a first subpath is found
|| pathlen > (int) fn.GetPath().Len() ) // or a better subpath if found
{
filename = fn.GetPathWithSep() + fn.GetFullName();
pathlen = fn.GetPath().Len();
}
fn = aFullFilename; //Try to find a better subpath
} }
} }
} }
......
...@@ -183,11 +183,13 @@ void DIALOG_MODULE_BOARD_EDITOR::InitModeditProperties() ...@@ -183,11 +183,13 @@ void DIALOG_MODULE_BOARD_EDITOR::InitModeditProperties()
while( draw3D ) while( draw3D )
{ {
S3D_MASTER* draw3DCopy = new S3D_MASTER(NULL); if( !draw3D->m_Shape3DName.IsEmpty() )
draw3DCopy->Copy( draw3D ); {
m_Shapes3D_list.push_back( draw3DCopy ); S3D_MASTER* draw3DCopy = new S3D_MASTER(NULL);
m_3D_ShapeNameListBox->Append(draw3DCopy->m_Shape3DName); draw3DCopy->Copy( draw3D );
m_Shapes3D_list.push_back( draw3DCopy );
m_3D_ShapeNameListBox->Append(draw3DCopy->m_Shape3DName);
}
draw3D = (S3D_MASTER*) draw3D->Next(); draw3D = (S3D_MASTER*) draw3D->Next();
} }
...@@ -297,7 +299,7 @@ void DIALOG_MODULE_BOARD_EDITOR::On3DShapeNameSelected(wxCommandEvent& event) ...@@ -297,7 +299,7 @@ void DIALOG_MODULE_BOARD_EDITOR::On3DShapeNameSelected(wxCommandEvent& event)
TransfertDisplayTo3DValues( m_LastSelected3DShapeIndex ); TransfertDisplayTo3DValues( m_LastSelected3DShapeIndex );
m_LastSelected3DShapeIndex = m_3D_ShapeNameListBox->GetSelection(); m_LastSelected3DShapeIndex = m_3D_ShapeNameListBox->GetSelection();
if( m_LastSelected3DShapeIndex < 0 ) // happens under wxGTK when deleting an item in m_3D_ShapeNameListBox wxListBox if( m_LastSelected3DShapeIndex < 0 ) // happens under wxGTK when deleting an item in m_3D_ShapeNameListBox wxListBox
return; return;
if( m_LastSelected3DShapeIndex >= (int) m_Shapes3D_list.size() ) if( m_LastSelected3DShapeIndex >= (int) m_Shapes3D_list.size() )
......
...@@ -46,9 +46,9 @@ DIALOG_MODULE_MODULE_EDITOR::~DIALOG_MODULE_MODULE_EDITOR() ...@@ -46,9 +46,9 @@ DIALOG_MODULE_MODULE_EDITOR::~DIALOG_MODULE_MODULE_EDITOR()
} }
/***************************************/ /********************************************************/
void DIALOG_MODULE_MODULE_EDITOR::InitModeditProperties() void DIALOG_MODULE_MODULE_EDITOR::InitModeditProperties()
/***************************************/ /********************************************************/
{ {
SetFocus(); SetFocus();
...@@ -59,11 +59,13 @@ void DIALOG_MODULE_MODULE_EDITOR::InitModeditProperties() ...@@ -59,11 +59,13 @@ void DIALOG_MODULE_MODULE_EDITOR::InitModeditProperties()
while( draw3D ) while( draw3D )
{ {
S3D_MASTER* draw3DCopy = new S3D_MASTER(NULL); if( !draw3D->m_Shape3DName.IsEmpty() )
draw3DCopy->Copy( draw3D ); {
m_Shapes3D_list.push_back( draw3DCopy ); S3D_MASTER* draw3DCopy = new S3D_MASTER(NULL);
m_3D_ShapeNameListBox->Append(draw3DCopy->m_Shape3DName); draw3DCopy->Copy( draw3D );
m_Shapes3D_list.push_back( draw3DCopy );
m_3D_ShapeNameListBox->Append(draw3DCopy->m_Shape3DName);
}
draw3D = (S3D_MASTER*) draw3D->Next(); draw3D = (S3D_MASTER*) draw3D->Next();
} }
...@@ -175,7 +177,7 @@ void DIALOG_MODULE_MODULE_EDITOR::On3DShapeNameSelected(wxCommandEvent& event) ...@@ -175,7 +177,7 @@ void DIALOG_MODULE_MODULE_EDITOR::On3DShapeNameSelected(wxCommandEvent& event)
TransfertDisplayTo3DValues( m_LastSelected3DShapeIndex ); TransfertDisplayTo3DValues( m_LastSelected3DShapeIndex );
m_LastSelected3DShapeIndex = m_3D_ShapeNameListBox->GetSelection(); m_LastSelected3DShapeIndex = m_3D_ShapeNameListBox->GetSelection();
if( m_LastSelected3DShapeIndex < 0 ) // happens under wxGTK when deleting an item in m_3D_ShapeNameListBox wxListBox if( m_LastSelected3DShapeIndex < 0 ) // happens under wxGTK when deleting an item in m_3D_ShapeNameListBox wxListBox
return; return;
if( m_LastSelected3DShapeIndex >= (int)m_Shapes3D_list.size() ) if( m_LastSelected3DShapeIndex >= (int)m_Shapes3D_list.size() )
......
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