Improve debugability of 3D file resolver failures.

Fixes https://gitlab.com/kicad/code/kicad/issues/7670
This commit is contained in:
Jeff Young 2021-09-14 12:20:35 +01:00
parent 5abe2572b9
commit 48082e3234
2 changed files with 12 additions and 16 deletions

View File

@ -305,7 +305,7 @@ wxString S3D_RESOLVER::ResolvePath( const wxString& aFileName )
{
tmpFN.Normalize();
tname = tmpFN.GetFullPath();
m_NameMap.insert( std::pair< wxString, wxString > ( aFileName, tname ) );
m_NameMap[ aFileName ] = tname;
// special case: if a path begins with ${ENV_VAR} but is not in the resolver's path list
// then add it
@ -320,7 +320,7 @@ wxString S3D_RESOLVER::ResolvePath( const wxString& aFileName )
if( aFileName.StartsWith( "${" ) || aFileName.StartsWith( "$(" ) )
{
m_errflags |= ERRFLG_ENVPATH;
return wxEmptyString;
return aFileName;
}
// at this point aFileName is:
@ -345,8 +345,7 @@ wxString S3D_RESOLVER::ResolvePath( const wxString& aFileName )
tmpFN.Assign( fullPath );
tmpFN.Normalize();
tname = tmpFN.GetFullPath();
m_NameMap.insert( std::pair< wxString, wxString > ( aFileName, tname ) );
m_NameMap[ aFileName ] = tname;
return tname;
}
}
@ -364,7 +363,7 @@ wxString S3D_RESOLVER::ResolvePath( const wxString& aFileName )
if( fpath.Normalize() && fpath.FileExists() )
{
tname = fpath.GetFullPath();
m_NameMap.insert( std::pair< wxString, wxString > ( aFileName, tname ) );
m_NameMap[ aFileName ] = tname;
return tname;
}
}
@ -378,7 +377,7 @@ wxString S3D_RESOLVER::ResolvePath( const wxString& aFileName )
// this can happen if the file was intended to be relative to ${KICAD6_3DMODEL_DIR}
// but ${KICAD6_3DMODEL_DIR} is not set or is incorrect.
m_errflags |= ERRFLG_RELPATH;
return wxEmptyString;
return aFileName;
}
for( const SEARCH_PATH& path : m_Paths )
@ -402,14 +401,14 @@ wxString S3D_RESOLVER::ResolvePath( const wxString& aFileName )
if( tmp.Normalize() )
tname = tmp.GetFullPath();
m_NameMap.insert( std::pair< wxString, wxString > ( aFileName, tname ) );
m_NameMap[ aFileName ] = tname;
return tname;
}
}
}
m_errflags |= ERRFLG_ALIAS;
return wxEmptyString;
return aFileName;
}

View File

@ -431,8 +431,7 @@ bool KICADFOOTPRINT::ComposePCB( class PCBMODEL* aPCB, S3D_RESOLVER* resolver,
if( mname.empty() )
{
ReportMessage( wxString::Format( "No model defined for component %s.\n",
m_refdes ) );
ReportMessage( wxString::Format( "No model defined for component %s.\n", m_refdes ) );
return false;
}
@ -440,14 +439,13 @@ bool KICADFOOTPRINT::ComposePCB( class PCBMODEL* aPCB, S3D_RESOLVER* resolver,
if( !wxFileName::FileExists( mname ) )
{
ReportMessage( wxString::Format( "Could not add component %s\n"
"File not found: %s\n ",
ReportMessage( wxString::Format( "Could not add component %s.\nFile not found: %s\n",
m_refdes,
mname ) );
return false;
}
std::string fname( resolver->ResolvePath( mname ).ToUTF8() );
std::string fname( mname.ToUTF8() );
try
{
@ -460,8 +458,7 @@ bool KICADFOOTPRINT::ComposePCB( class PCBMODEL* aPCB, S3D_RESOLVER* resolver,
}
catch( const Standard_Failure& e)
{
ReportMessage( wxString::Format( "Could not add component %s\n"
"Open CASCADE error: %s\n ",
ReportMessage( wxString::Format( "Could not add component %s.\nOpenCASCADE error: %s\n",
m_refdes,
e.GetMessageString() ) );
}