Display all "File couldn't be found" messages at the end.

Fixes: lp:1810161
* https://bugs.launchpad.net/kicad/+bug/1810161
This commit is contained in:
Jeff Young 2019-07-10 18:59:39 +01:00
parent ff9d899ae0
commit 5c43924338
11 changed files with 39 additions and 198 deletions

View File

@ -164,28 +164,6 @@ void PART_LIB::GetAliases( std::vector<LIB_ALIAS*>& aAliases ) const
}
void PART_LIB::GetEntryTypePowerNames( wxArrayString& aNames ) const
{
std::vector<LIB_ALIAS*> aliases;
m_plugin->EnumerateSymbolLib( aliases, fileName.GetFullPath() );
for( size_t i = 0; i < aliases.size(); i++ )
{
LIB_ALIAS* alias = aliases[i];
LIB_PART* root = alias->GetPart();
if( !root || !root->IsPower() )
continue;
aNames.Add( alias->GetName() );
}
aNames.Sort();
}
LIB_ALIAS* PART_LIB::FindAlias( const wxString& aName ) const
{
LIB_ALIAS* alias = m_plugin->LoadSymbol( fileName.GetFullPath(), aName, m_properties.get() );
@ -223,27 +201,6 @@ LIB_PART* PART_LIB::FindPart( const LIB_ID& aLibId ) const
}
bool PART_LIB::HasPowerParts() const
{
// return true if at least one power part is found in lib
std::vector<LIB_ALIAS*> aliases;
m_plugin->EnumerateSymbolLib( aliases, fileName.GetFullPath(), m_properties.get() );
for( size_t i = 0; i < aliases.size(); i++ )
{
LIB_ALIAS* alias = aliases[i];
LIB_PART* root = alias->GetPart();
if( !root || root->IsPower() )
return true;
}
return false;
}
void PART_LIB::AddPart( LIB_PART* aPart )
{
// add a clone, not the caller's copy, the plugin take ownership of the new symbol.

View File

@ -344,26 +344,6 @@ public:
void SetFileName( const wxString& aFileName ) { fileName = aFileName; }
/**
* Get library entry status.
*
* @return True if there are no entries in the library.
*/
bool IsEmpty() const
{
return m_plugin->GetSymbolLibCount( fileName.GetFullPath() ) == 0;
}
/**
* Return the number of entries in the library.
*
* @return The number of part and alias entries.
*/
int GetCount() const
{
return (int) m_plugin->GetSymbolLibCount( fileName.GetFullPath() );
}
bool IsModified() const
{
return isModified;
@ -398,13 +378,6 @@ public:
*/
void GetAliases( std::vector<LIB_ALIAS*>& aAliases ) const;
/**
* Load a string array with the names of entries of type POWER in this library.
*
* @param aNames - String array to place entry names into.
*/
void GetEntryTypePowerNames( wxArrayString& aNames ) const;
/**
* Find #LIB_ALIAS by \a aName.
*
@ -501,12 +474,6 @@ public:
* @throw IO_ERROR if there's any problem loading the library.
*/
static PART_LIB* LoadLibrary( const wxString& aFileName );
/**
* @return true if at least one power part is found in lib
* Useful to select or list only libs containing power parts
*/
bool HasPowerParts() const;
};

View File

@ -27,7 +27,6 @@
#include <class_libentry.h>
#include <class_library.h>
#include <lib_edit_frame.h>
#include <confirm.h>
#include <env_paths.h>
#include <pgm_base.h>
#include <kiway.h>
@ -49,6 +48,8 @@ LIB_MANAGER::LIB_MANAGER( LIB_EDIT_FRAME& aFrame ) :
void LIB_MANAGER::Sync( bool aForce,
std::function<void( int, int, const wxString& )> aProgressCallback )
{
m_logger.Activate();
int libTableHash = symTable()->GetModifyHash();
if( aForce || m_syncHash != libTableHash )
@ -61,7 +62,7 @@ void LIB_MANAGER::Sync( bool aForce,
bool LIB_MANAGER::HasModifications() const
{
for( auto lib : m_libs )
for( const auto& lib : m_libs )
{
if( lib.second.IsModified() )
return true;
@ -75,8 +76,8 @@ int LIB_MANAGER::GetHash() const
{
int hash = symTable()->GetModifyHash();
for( const auto& libBuf : m_libs )
hash += libBuf.second.GetHash();
for( const auto& lib : m_libs )
hash += lib.second.GetHash();
return hash;
}
@ -296,33 +297,6 @@ bool LIB_MANAGER::IsLibraryReadOnly( const wxString& aLibrary ) const
}
wxArrayString LIB_MANAGER::GetAliasNames( const wxString& aLibrary ) const
{
wxArrayString names;
wxCHECK( LibraryExists( aLibrary ), names );
auto it = m_libs.find( aLibrary );
if( it == m_libs.end() )
{
try
{
symTable()->EnumerateSymbolLib( aLibrary, names );
}
catch( const IO_ERROR& e )
{
wxLogMessage( _( "Cannot enumerate library \"%s\" (%s)" ), aLibrary, e.What() );
}
}
else
{
names = it->second.GetAliasNames();
}
return names;
}
std::list<LIB_ALIAS*> LIB_MANAGER::GetAliases( const wxString& aLibrary ) const
{
std::list<LIB_ALIAS*> ret;
@ -348,7 +322,7 @@ std::list<LIB_ALIAS*> LIB_MANAGER::GetAliases( const wxString& aLibrary ) const
}
catch( const IO_ERROR& e )
{
wxLogMessage( _( "Cannot load aliases from library \"%s\" (%s)" ), aLibrary, e.What() );
wxLogWarning( e.Problem() );
}
std::copy( aliases.begin(), aliases.end(), std::back_inserter( ret ) );
@ -637,26 +611,6 @@ wxString LIB_MANAGER::GetUniqueLibraryName() const
}
wxString LIB_MANAGER::GetUniqueComponentName( const wxString& aLibrary ) const
{
wxString name = "New_Component";
if( !PartExists( name, aLibrary ) )
return name;
name += "_";
for( unsigned int i = 0; i < std::numeric_limits<unsigned int>::max(); ++i )
{
if( !PartExists( name + wxString::Format( "%u", i ), aLibrary ) )
return name + wxString::Format( "%u", i );
}
wxFAIL;
return wxEmptyString;
}
wxString LIB_MANAGER::getLibraryName( const wxString& aFilePath )
{
wxFileName fn( aFilePath );

View File

@ -44,6 +44,33 @@ class LIB_EDIT_FRAME;
class SYMBOL_LIB_TABLE;
class SYMBOL_LIB_TABLE_ROW;
class LIB_LOGGER : public wxLogGui
{
public:
void Activate()
{
m_previousLogger = wxLog::GetActiveTarget();
wxLog::SetActiveTarget( this );
}
void Flush() override
{
if( m_bHasMessages )
{
wxLogMessage( _( "Not all libraries could be loaded. Use the Manage Symbol Libraries dialog \n"
"to adjust paths and add or remove libraries." ) );
wxLogGui::Flush();
wxLog::SetActiveTarget( m_previousLogger );
}
}
private:
wxLog* m_previousLogger;
};
/**
* Class to handle modifications to the symbol libraries.
*/
@ -81,11 +108,6 @@ public:
*/
SYMBOL_LIB_TABLE_ROW* GetLibrary( const wxString& aLibrary ) const;
/**
* Returns a set containing all part names for a specific library.
*/
wxArrayString GetAliasNames( const wxString& aLibrary ) const;
std::list<LIB_ALIAS*> GetAliases( const wxString& aLibrary ) const;
/**
@ -233,12 +255,6 @@ public:
*/
wxString GetUniqueLibraryName() const;
/**
* Returns a component name that is not stored in a library.
* Used for generating names for new components.
*/
wxString GetUniqueComponentName( const wxString& aLibrary ) const;
/**
* Returns the adapter object that provides the stored data.
*/
@ -449,14 +465,11 @@ private:
///> The library buffers
std::map<wxString, LIB_BUFFER> m_libs;
///> Symbol Lib Table hash value returned during the last synchronization
int m_syncHash;
LIB_LOGGER m_logger;
int m_syncHash; // Symbol Lib Table hash value from the last synchronization
///> Currently modified part
wxString m_currentLib;
///> Currently modified library
wxString m_currentPart;
wxString m_currentLib; // Currently modified part
wxString m_currentPart; // Currently modified library
SYMBOL_TREE_SYNCHRONIZING_ADAPTER::PTR m_adapter;
SYMBOL_TREE_SYNCHRONIZING_ADAPTER* getAdapter()

View File

@ -103,9 +103,6 @@ public:
//void Save( const wxString& aFileName, SCH_SCREEN* aSchematic, KIWAY* aKiway,
// const PROPERTIES* aProperties = NULL ) override;
//size_t GetSymbolLibCount( const wxString& aLibraryPath,
// const PROPERTIES* aProperties = NULL ) override;
//void EnumerateSymbolLib( wxArrayString& aAliasNameList, const wxString& aLibraryPath,
// const PROPERTIES* aProperties = NULL ) override;

View File

@ -271,9 +271,6 @@ public:
virtual void Save( const wxString& aFileName, SCH_SCREEN* aSchematic, KIWAY* aKiway,
const PROPERTIES* aProperties = NULL );
virtual size_t GetSymbolLibCount( const wxString& aLibraryPath,
const PROPERTIES* aProperties = NULL );
/**
* Populate a list of #LIB_PART alias names contained within the library \a aLibraryPath.
*

View File

@ -2444,14 +2444,8 @@ void SCH_LEGACY_PLUGIN_CACHE::Load()
{
if( !m_libFileName.FileExists() )
{
wxString msg = wxString::Format( _( "Library file \"%s\" not found.\n\n"
"Use the Manage Symbol Libraries dialog to fix the "
"path (or remove the library)." ),
m_libFileName.GetFullPath() );
KIDIALOG dlg( Pgm().App().GetTopWindow(), msg, KIDIALOG::KD_ERROR );
dlg.DoNotShowCheckbox( __FILE__, __LINE__ );
dlg.ShowModal();
return;
THROW_IO_ERROR( wxString::Format( _( "Library file \"%s\" not found." ),
m_libFileName.GetFullPath() ) );
}
wxCHECK_RET( m_libFileName.IsAbsolute(),
@ -4247,19 +4241,6 @@ int SCH_LEGACY_PLUGIN::GetModifyHash() const
}
size_t SCH_LEGACY_PLUGIN::GetSymbolLibCount( const wxString& aLibraryPath,
const PROPERTIES* aProperties )
{
LOCALE_IO toggle;
m_props = aProperties;
cacheLib( aLibraryPath );
return m_cache->m_aliases.size();
}
void SCH_LEGACY_PLUGIN::EnumerateSymbolLib( wxArrayString& aAliasNameList,
const wxString& aLibraryPath,
const PROPERTIES* aProperties )

View File

@ -111,8 +111,6 @@ public:
void Format( SELECTION* aSelection, OUTPUTFORMATTER* aFormatter );
size_t GetSymbolLibCount( const wxString& aLibraryPath,
const PROPERTIES* aProperties = nullptr ) override;
void EnumerateSymbolLib( wxArrayString& aAliasNameList,
const wxString& aLibraryPath,
const PROPERTIES* aProperties = nullptr ) override;

View File

@ -63,15 +63,6 @@ void SCH_PLUGIN::Save( const wxString& aFileName, SCH_SCREEN* aSchematic, KIWAY*
}
size_t SCH_PLUGIN::GetSymbolLibCount( const wxString& aLibraryPath,
const PROPERTIES* aProperties )
{
// not pure virtual so that plugins only have to implement subset of the SCH_PLUGIN interface.
not_implemented( this, __FUNCTION__ );
return 0;
}
void SCH_PLUGIN::EnumerateSymbolLib( wxArrayString& aAliasNameList,
const wxString& aLibraryPath,
const PROPERTIES* aProperties )

View File

@ -261,15 +261,6 @@ int SYMBOL_LIB_TABLE::GetModifyHash()
}
size_t SYMBOL_LIB_TABLE::GetSymbolCount( const wxString& aNickname )
{
SYMBOL_LIB_TABLE_ROW* row = dynamic_cast< SYMBOL_LIB_TABLE_ROW* >( findRow( aNickname ) );
wxCHECK( row && row->plugin, 0 );
return row->plugin->GetSymbolLibCount( row->GetFullURI( true ) );
}
void SYMBOL_LIB_TABLE::EnumerateSymbolLib( const wxString& aNickname, wxArrayString& aAliasNames,
bool aPowerSymbolsOnly )
{

View File

@ -145,11 +145,6 @@ public:
//-----<PLUGIN API SUBSET, REBASED ON aNickname>---------------------------
/**
* Return the number of symbols in the symbol library mapped to \a aNickname
*/
size_t GetSymbolCount( const wxString& aNickname );
/**
* Return a list of symbol alias names contained within the library given by @a aNickname.
*