From 0fcf722af408509bf37e509583998eac81356558 Mon Sep 17 00:00:00 2001 From: Wayne Stambaugh Date: Fri, 7 Jun 2013 08:15:32 -0400 Subject: [PATCH] Fix CvPcb library filtering bug. (fixes lp:1188321) --- common/footprint_info.cpp | 23 +++++++++++++++++++++++ cvpcb/class_footprints_listbox.cpp | 2 +- include/footprint_info.h | 26 +++++++++++++++++++------- 3 files changed, 43 insertions(+), 8 deletions(-) diff --git a/common/footprint_info.cpp b/common/footprint_info.cpp index cc5368a5af..810076be05 100644 --- a/common/footprint_info.cpp +++ b/common/footprint_info.cpp @@ -180,3 +180,26 @@ bool FOOTPRINT_LIST::ReadFootprintFiles( FP_LIB_TABLE& aTable ) return true; } + + +bool FOOTPRINT_INFO::InLibrary( const wxString& aLibrary ) const +{ + if( aLibrary.IsEmpty() ) + return false; + + if( aLibrary == m_libName || aLibrary == m_libPath ) + return true; + + wxFileName filename = aLibrary; + + if( filename.GetExt().IsEmpty() ) + filename.SetExt( LegacyFootprintLibPathExtension ); + + if( filename.GetFullPath() == m_libPath ) + return true; + + if( filename.GetPath().IsEmpty() ) + filename = wxGetApp().FindLibraryPath( filename.GetFullName() ); + + return filename.GetFullPath() == m_libPath; +} diff --git a/cvpcb/class_footprints_listbox.cpp b/cvpcb/class_footprints_listbox.cpp index 8d7ab4e930..3fb5874f30 100644 --- a/cvpcb/class_footprints_listbox.cpp +++ b/cvpcb/class_footprints_listbox.cpp @@ -142,7 +142,7 @@ void FOOTPRINTS_LISTBOX::SetFootprints( FOOTPRINT_LIST& aList, const wxString& a } if( (aFilterType & BY_LIBRARY) && !aLibName.IsEmpty() - && (aList.GetItem( ii ).m_libName != aLibName) ) + && !aList.GetItem( ii ).InLibrary( aLibName ) ) continue; if( (aFilterType & BY_COMPONENT) && (aComponent != NULL) diff --git a/include/footprint_info.h b/include/footprint_info.h index 70678b24fa..ccdba621db 100644 --- a/include/footprint_info.h +++ b/include/footprint_info.h @@ -29,6 +29,7 @@ #ifndef FOOTPRINT_INFO_H_ #define FOOTPRINT_INFO_H_ + #include #include @@ -46,13 +47,13 @@ class FP_LIB_TABLE; class FOOTPRINT_INFO { public: - wxString m_libName; ///< Name of the library containing this module excluding path and ext. - wxString m_libPath; ///< The full library name and path associated the footprint. - wxString m_Module; ///< Module name. - int m_Num; ///< Order number in the display list. - wxString m_Doc; ///< Footprint description. - wxString m_KeyWord; ///< Footprint key words. - unsigned m_padCount; ///< Number of pads + wxString m_libName; ///< Name of the library containing this module excluding path and ext. + wxString m_libPath; ///< The full library name and path associated the footprint. + wxString m_Module; ///< Module name. + int m_Num; ///< Order number in the display list. + wxString m_Doc; ///< Footprint description. + wxString m_KeyWord; ///< Footprint key words. + unsigned m_padCount; ///< Number of pads FOOTPRINT_INFO() { @@ -67,6 +68,17 @@ public: void SetLibraryPath( const wxString& aLibPath ) { m_libPath = aLibPath; } const wxString& GetLibraryPath() const { return m_libPath; } + + /** + * Function InLibrary + * tests if the #FOOTPRINT_INFO object was loaded from \a aLibrary. + * + * @param aLibrary is the file name or the fully qualified path and file name + * to test. + * @return true if the #FOOTPRINT_INFO object was loaded from \a aLibrary. Otherwise + * false. + */ + bool InLibrary( const wxString& aLibrary ) const; };