← Back to team overview

kicad-developers team mailing list archive

cvpcb module subdirectory [PATCH]

 

Hello,

I found problem in cvpcb. When module is in subdirectory and I use "Filter the footprint list by selected library", and click on this library, nothing shows in footprints column.

For example, I have standard path /usr/share/kicad/modules and:
connect - is OK
discret - is OK
Sensors/Pressure - not displays
Inductor/Inductors_SMD - not displays

I downloaded form launchpad thru bzr, dated 2013-09-14 and debug it. And found problem in file common/footprint_info.cpp:

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;
}

And two last line I don't understand:

*I think, there shut be negation, or this line should not be used at all, because it is not empty, when using subdirectory*
     if( filename.GetPath().IsEmpty() )
*And this line returns only name without subdirectory, and so will not work with subdirectory*
        filename = wxGetApp().FindLibraryPath( filename.GetFullName() );

So i tried to change this function (last two lines):

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.*GetFullPath*() );

    return filename.GetFullPath() == m_libPath;
}

And it is now working correct with subdirectory. So I am not sure about first line to use it ever.

Michal Jahelka
=== modified file 'common/footprint_info.cpp'
--- common/footprint_info.cpp	2013-06-07 13:17:52 +0000
+++ common/footprint_info.cpp	2013-09-14 15:47:42 +0000
@@ -198,8 +198,8 @@
     if( filename.GetFullPath() == m_libPath )
         return true;
 
-    if( filename.GetPath().IsEmpty() )
-        filename = wxGetApp().FindLibraryPath( filename.GetFullName() );
+    if( !filename.GetPath().IsEmpty() )
+        filename = wxGetApp().FindLibraryPath( filename.GetFullPath() );
 
     return filename.GetFullPath() == m_libPath;
 }