kicad-developers team mailing list archive
-
kicad-developers team
-
Mailing list archive
-
Message #14373
Re: Eeschema issue: cannot load component from multi libraries with same component name
>> I will do the "workaround" reordering of my libraries.. not a problem for me now that I know how it works..
>
>
> I think the sort() call has to go, so I now think you discovered something.
>
> Should have a fix in minutes.
>
> When the foundations get simpler, so do the algorithms.
>
>
> Dick
This one simplifies everything by removing the sort() and the sortOrder support. The
library list is loaded in the proper order, I know of no reason to sort it.
Guys please try this one instead of other, and comment.
It is even simpler yet, and gets rid of the sort-order global which *would not fly* in a
multiple project situation.
Dick
=== modified file 'eeschema/class_library.cpp'
--- eeschema/class_library.cpp 2014-08-13 20:28:54 +0000
+++ eeschema/class_library.cpp 2014-08-18 21:42:33 +0000
@@ -53,51 +53,6 @@
"This may cause some unexpected behavior when loading components into a schematic." )
-bool operator==( const PART_LIB& aLibrary, const wxString& aName )
-{
- // See our header class_libentry.h for function Cmp_KEEPCASE().
- return Cmp_KEEPCASE( aLibrary.GetName(), aName ) == 0;
-}
-
-
-bool operator!=( const PART_LIB& aLibrary, const wxString& aName )
-{
- return !( aLibrary == aName );
-}
-
-
-wxArrayString PART_LIBS::s_libraryListSortOrder;
-
-
-bool operator<( const PART_LIB& aItem1, const PART_LIB& aItem2 )
-{
- // The cache library always is sorted to the end of the library list.
- if( aItem2.IsCache() )
- return true;
-
- if( aItem1.IsCache() )
- return false;
-
- // If the sort order array isn't set, then sort alphabetically except.
- if( PART_LIBS::GetSortOrder().IsEmpty() )
- return Cmp_KEEPCASE( aItem1.GetName(), aItem2.GetName() ) < 0;
-
- int i1 = PART_LIBS::GetSortOrder().Index( aItem1.GetName(), false );
- int i2 = PART_LIBS::GetSortOrder().Index( aItem2.GetName(), false );
-
- if( i1 == wxNOT_FOUND && i2 == wxNOT_FOUND )
- return true;
-
- if( i1 == wxNOT_FOUND && i2 != wxNOT_FOUND )
- return false;
-
- if( i1 != wxNOT_FOUND && i2 == wxNOT_FOUND )
- return true;
-
- return ( i1 - i2 ) < 0;
-}
-
-
PART_LIB::PART_LIB( int aType, const wxString& aFileName ) :
// start @ != 0 so each additional library added
// is immediately detectable, zero would not be.
@@ -873,19 +828,11 @@
PART_LIB* PART_LIBS::FindLibrary( const wxString& aName )
{
-#if 0
- BOOST_FOREACH( PART_LIB& lib, *this )
- {
- if( lib == aName )
- return &lib;
- }
-#else
for( PART_LIBS::iterator it = begin(); it!=end(); ++it )
{
- if( *it == aName )
+ if( it->GetName() == aName )
return &*it;
}
-#endif
return NULL;
}
@@ -1057,7 +1004,6 @@
wxFileName fn;
wxString filename;
wxString libs_not_found;
- wxArrayString sortOrder;
SEARCH_STACK* lib_search = aProject->SchSearchS();
#if defined(DEBUG) && 1
@@ -1147,18 +1093,8 @@
UTF8( libs_not_found ), 0, 0 );
}
- // Put the libraries in the correct order.
- PART_LIBS::SetSortOrder( sortOrder );
-
- sort();
-
#if defined(DEBUG) && 1
- printf( "%s: sort order:\n", __func__ );
-
- for( size_t i = 0; i < sortOrder.GetCount(); i++ )
- printf( " %s\n", TO_UTF8( sortOrder[i] ) );
-
- printf( "%s: actual order:\n", __func__ );
+ printf( "%s: lib_names:\n", __func__ );
for( PART_LIBS::const_iterator it = begin(); it < end(); ++it )
printf( " %s\n", TO_UTF8( it->GetName() ) );
=== modified file 'eeschema/class_library.h'
--- eeschema/class_library.h 2014-08-13 20:28:54 +0000
+++ eeschema/class_library.h 2014-08-18 21:36:19 +0000
@@ -103,8 +103,6 @@
*/
class PART_LIBS : public PART_LIBS_BASE, public PROJECT::_ELEM
{
- static wxArrayString s_libraryListSortOrder;
-
public:
static int s_modify_generation; ///< helper for GetModifyHash()
@@ -226,21 +224,9 @@
int GetLibraryCount() { return size(); }
- static void SetSortOrder( const wxArrayString& aSortOrder )
- {
- s_libraryListSortOrder = aSortOrder;
- }
-
- static wxArrayString& GetSortOrder()
- {
- return s_libraryListSortOrder;
- }
};
-bool operator<( const PART_LIB& item1, const PART_LIB& item2 );
-
-
/**
* Class PART_LIB
* is used to load, save, search, and otherwise manipulate
Follow ups
References