Commit 076c2c76 authored by Wayne Stambaugh's avatar Wayne Stambaugh

Pcbnew footprint library table fixes.

* Make footprint editor work properly with library table.
* Fix bug in Eagle plugin when comparing file timestamps.
* Fix bug in footprint viewer when error occur loading footprints from
  the selected library.
* Fix error message display by in footprint viewer on library load error.
parent de4cceb2
...@@ -93,6 +93,9 @@ typedef boost::optional<double> opt_double; ...@@ -93,6 +93,9 @@ typedef boost::optional<double> opt_double;
typedef boost::optional<bool> opt_bool; typedef boost::optional<bool> opt_bool;
const wxChar* traceEaglePlugin = wxT( "KicadEaglePlugin" );
/// segment (element) of our XPATH into the Eagle XML document tree in PTREE form. /// segment (element) of our XPATH into the Eagle XML document tree in PTREE form.
struct TRIPLET struct TRIPLET
{ {
...@@ -2731,15 +2734,17 @@ void EAGLE_PLUGIN::cacheLib( const wxString& aLibPath ) ...@@ -2731,15 +2734,17 @@ void EAGLE_PLUGIN::cacheLib( const wxString& aLibPath )
{ {
try try
{ {
wxDateTime modtime; wxDateTime modtime = getModificationTime( aLibPath );
if( !m_mod_time.IsValid() ) // Fixes assertions in wxWidgets debug builds for the wxDateTime object. Refresh the
m_mod_time.Now(); // cache if either of the wxDateTime objects are invalid or the last file modification
// time differs from the current file modification time.
bool load = !m_mod_time.IsValid() || !modtime.IsValid() ||
m_mod_time != modtime;
if( aLibPath != m_lib_path || if( aLibPath != m_lib_path || load )
m_mod_time != ( modtime = getModificationTime( aLibPath ) ) )
{ {
//D(printf("Loading '%s'\n", TO_UTF8( aLibPath ) );) wxLogTrace( traceEaglePlugin, wxT( "Loading '%s'" ), TO_UTF8( aLibPath ) );
PTREE doc; PTREE doc;
LOCALE_IO toggle; // toggles on, then off, the C locale. LOCALE_IO toggle; // toggles on, then off, the C locale.
......
...@@ -825,20 +825,10 @@ void FOOTPRINT_EDIT_FRAME::Select_Active_Library() ...@@ -825,20 +825,10 @@ void FOOTPRINT_EDIT_FRAME::Select_Active_Library()
wxString uri = m_footprintLibTable->FindRow( dlg.GetTextSelection() )->GetFullURI(); wxString uri = m_footprintLibTable->FindRow( dlg.GetTextSelection() )->GetFullURI();
wxFileName fileName = FP_LIB_TABLE::ExpandSubstitutions( uri ); wxFileName fileName = FP_LIB_TABLE::ExpandSubstitutions( uri );
if( fileName.IsOk() && fileName.FileExists() ) wxLogDebug( wxT( "Loading footprint library <%s> from <%s>." ),
{ GetChars( dlg.GetTextSelection() ), GetChars( fileName.GetFullPath() ) );
setLibPath( fileName.GetFullPath() );
}
else
{
wxString msg = wxString::Format( FMT_BAD_PATHS, GetChars( dlg.GetTextSelection() ) );
DisplayError( this, msg );
setLibNickName( wxEmptyString );
setLibPath( wxEmptyString );
}
setLibPath( fileName.GetFullPath() );
updateTitle(); updateTitle();
} }
......
...@@ -511,7 +511,21 @@ wxString PCB_BASE_FRAME::SelectFootprint( EDA_DRAW_FRAME* aWindow, ...@@ -511,7 +511,21 @@ wxString PCB_BASE_FRAME::SelectFootprint( EDA_DRAW_FRAME* aWindow,
return wxEmptyString; return wxEmptyString;
} }
MList.ReadFootprintFiles( libTable ); if( !MList.ReadFootprintFiles( libTable ) )
{
msg.Format( _( "Error occurred attempting to load footprint library <%s>:\n\n" ),
GetChars( aLibraryFullFilename ) );
if( !MList.m_filesNotFound.IsEmpty() )
msg += _( "Files not found:\n\n" ) + MList.m_filesNotFound;
if( !MList.m_filesInvalid.IsEmpty() )
msg += _("\n\nFile load errors:\n\n" ) + MList.m_filesInvalid;
DisplayError( this, msg );
return wxEmptyString;
}
#endif #endif
if( MList.GetCount() == 0 ) if( MList.GetCount() == 0 )
......
...@@ -429,7 +429,6 @@ void FOOTPRINT_VIEWER_FRAME::ReCreateFootprintList() ...@@ -429,7 +429,6 @@ void FOOTPRINT_VIEWER_FRAME::ReCreateFootprintList()
bool libLoaded = false; bool libLoaded = false;
FOOTPRINT_LIST fp_info_list; FOOTPRINT_LIST fp_info_list;
wxArrayString libsList; wxArrayString libsList;
wxBusyCursor busyCursor;
#if !defined( USE_FP_LIB_TABLE ) #if !defined( USE_FP_LIB_TABLE )
libsList.Add( m_libraryName ); libsList.Add( m_libraryName );
...@@ -453,11 +452,18 @@ void FOOTPRINT_VIEWER_FRAME::ReCreateFootprintList() ...@@ -453,11 +452,18 @@ void FOOTPRINT_VIEWER_FRAME::ReCreateFootprintList()
if( !libLoaded ) if( !libLoaded )
{ {
m_libraryName = wxEmptyString;
wxString msg; wxString msg;
msg.Format( _( "Error occurred attempting to load footprint library <%s>:\n\n" msg.Format( _( "Error occurred attempting to load footprint library <%s>:\n\n" ),
"Files not found:\n\n%s\n\nFile load errors:\n\n%s" ), GetChars( m_libraryName ) );
GetChars( m_libraryName ), GetChars( fp_info_list.m_filesNotFound ),
GetChars( fp_info_list.m_filesInvalid ) ); if( !fp_info_list.m_filesNotFound.IsEmpty() )
msg += _( "Files not found:\n\n" ) + fp_info_list.m_filesNotFound;
if( !fp_info_list.m_filesInvalid.IsEmpty() )
msg += _("\n\nFile load errors:\n\n" ) + fp_info_list.m_filesInvalid;
DisplayError( this, msg ); DisplayError( this, msg );
return; return;
} }
...@@ -502,6 +508,9 @@ void FOOTPRINT_VIEWER_FRAME::ClickOnLibList( wxCommandEvent& event ) ...@@ -502,6 +508,9 @@ void FOOTPRINT_VIEWER_FRAME::ClickOnLibList( wxCommandEvent& event )
void FOOTPRINT_VIEWER_FRAME::ClickOnFootprintList( wxCommandEvent& event ) void FOOTPRINT_VIEWER_FRAME::ClickOnFootprintList( wxCommandEvent& event )
{ {
if( m_FootprintList->GetCount() == 0 )
return;
int ii = m_FootprintList->GetSelection(); int ii = m_FootprintList->GetSelection();
if( ii < 0 ) if( ii < 0 )
......
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