Improve symbol library messages.
Includes both error messages and ERC messages. Fixes https://gitlab.com/kicad/code/kicad/issues/6302
This commit is contained in:
parent
01f6c90fac
commit
5d400a9e11
|
@ -57,11 +57,10 @@ bool DIALOG_GLOBAL_SYM_LIB_TABLE_CONFIG::TransferDataFromWindow()
|
|||
}
|
||||
catch( const IO_ERROR& ioe )
|
||||
{
|
||||
DisplayError( this,
|
||||
wxString::Format( _( "Error occurred writing empty symbol library table "
|
||||
"file.\n\n%s" ),
|
||||
SYMBOL_LIB_TABLE::GetGlobalTableFileName(),
|
||||
ioe.What() ) );
|
||||
DisplayError( this, wxString::Format( _( "Error occurred writing empty symbol library "
|
||||
"table.\n\n%s" ),
|
||||
SYMBOL_LIB_TABLE::GetGlobalTableFileName(),
|
||||
ioe.What() ) );
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -81,8 +80,7 @@ bool DIALOG_GLOBAL_SYM_LIB_TABLE_CONFIG::TransferDataFromWindow()
|
|||
// Make sure the symbol library table to copy actually exists.
|
||||
if( !fn.FileExists() )
|
||||
{
|
||||
DisplayError( this,
|
||||
wxString::Format( _( "File \"%s\" not found." ), fn.GetFullPath() ) );
|
||||
DisplayError( this, wxString::Format( _( "File '%s' not found." ), fn.GetFullPath() ) );
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -95,9 +93,9 @@ bool DIALOG_GLOBAL_SYM_LIB_TABLE_CONFIG::TransferDataFromWindow()
|
|||
}
|
||||
catch( const IO_ERROR& ioe )
|
||||
{
|
||||
DisplayError( this,
|
||||
wxString::Format( _( "File \"%s\" is not a valid symbol library table "
|
||||
"file.\n\n%s" ), fn.GetFullPath(), ioe.What() ) );
|
||||
DisplayError( this, wxString::Format( _( "'%s' is not a valid symbol library table.\n\n%s" ),
|
||||
fn.GetFullPath(),
|
||||
ioe.What() ) );
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -106,19 +104,18 @@ bool DIALOG_GLOBAL_SYM_LIB_TABLE_CONFIG::TransferDataFromWindow()
|
|||
|
||||
if( !symTableFileName.DirExists() && !symTableFileName.Mkdir( 0x777, wxPATH_MKDIR_FULL ) )
|
||||
{
|
||||
DisplayError( this,
|
||||
wxString::Format( _( "Cannot create global library table path \"%s\"." ),
|
||||
symTableFileName.GetPath() ) );
|
||||
DisplayError( this, wxString::Format( _( "Cannot create global library table path '%s'." ),
|
||||
symTableFileName.GetPath() ) );
|
||||
return false;
|
||||
}
|
||||
|
||||
// Copy the global symbol library table file to the user config.
|
||||
if( !::wxCopyFile( fn.GetFullPath(), symTableFileName.GetFullPath() ) )
|
||||
{
|
||||
DisplayError( this,
|
||||
wxString::Format( _( "Cannot copy global symbol library table "
|
||||
"file:\n\n \"%s\"\n\n:to:\n\n\"%s\"." ),
|
||||
fn.GetFullPath(), symTableFileName.GetFullPath() ) );
|
||||
DisplayError( this, wxString::Format( _( "Cannot copy global symbol library table file "
|
||||
"'%s' to '%s'." ),
|
||||
fn.GetFullPath(),
|
||||
symTableFileName.GetFullPath() ) );
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -132,9 +129,9 @@ bool DIALOG_GLOBAL_SYM_LIB_TABLE_CONFIG::TransferDataFromWindow()
|
|||
}
|
||||
catch( const IO_ERROR& ioe )
|
||||
{
|
||||
DisplayError( this,
|
||||
wxString::Format( _( "Error occurred loading global symbol library table:"
|
||||
"\n\n%s" ), ioe.What() ) );
|
||||
DisplayError( this, wxString::Format( _( "Error occurred loading global symbol library "
|
||||
"table.\n\n%s" ),
|
||||
ioe.What() ) );
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -675,8 +675,9 @@ int ERC_TESTER::TestLibSymbolIssues()
|
|||
{
|
||||
wxCHECK( m_schematic, 0 );
|
||||
|
||||
wxString msg;
|
||||
int err_count = 0;
|
||||
SYMBOL_LIB_TABLE* libTable = m_schematic->Prj().SchSymbolLibTable();
|
||||
wxString msg;
|
||||
int err_count = 0;
|
||||
|
||||
SCH_SCREENS screens( m_schematic->Root() );
|
||||
|
||||
|
@ -690,38 +691,65 @@ int ERC_TESTER::TestLibSymbolIssues()
|
|||
|
||||
wxCHECK2( symbol, continue );
|
||||
|
||||
LIB_PART* libSymbolInSchematic = screen->GetLibSymbols()[
|
||||
symbol->GetLibId().GetUniStringLibId() ];
|
||||
wxString libIdStr = symbol->GetLibId().GetUniStringLibId();
|
||||
LIB_PART* libSymbolInSchematic = screen->GetLibSymbols()[ libIdStr ];
|
||||
|
||||
wxCHECK2( libSymbolInSchematic, continue );
|
||||
|
||||
LIB_PART* libSymbol = SchGetLibPart( symbol->GetLibId(),
|
||||
m_schematic->Prj().SchSymbolLibTable() );
|
||||
wxString libName = symbol->GetLibId().GetLibNickname();
|
||||
LIB_TABLE_ROW* libTableRow = libTable->FindRow( libName );
|
||||
|
||||
if( !libTableRow )
|
||||
{
|
||||
std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_LIB_SYMBOL_ISSUES );
|
||||
ercItem->SetItems( symbol );
|
||||
msg.Printf( _( "The current configuration does not include the library '%s'." ),
|
||||
libName );
|
||||
ercItem->SetErrorMessage( msg );
|
||||
|
||||
markers.emplace_back( new SCH_MARKER( ercItem, symbol->GetPosition() ) );
|
||||
break;
|
||||
}
|
||||
else if( !libTable->HasLibrary( libName, true ) )
|
||||
{
|
||||
std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_LIB_SYMBOL_ISSUES );
|
||||
ercItem->SetItems( symbol );
|
||||
msg.Printf( _( "The library '%s' is not enabled in the current configuration." ),
|
||||
libName );
|
||||
ercItem->SetErrorMessage( msg );
|
||||
|
||||
markers.emplace_back( new SCH_MARKER( ercItem, symbol->GetPosition() ) );
|
||||
break;
|
||||
}
|
||||
|
||||
wxString symbolName = symbol->GetLibId().GetLibItemName();
|
||||
LIB_PART* libSymbol = SchGetLibPart( symbol->GetLibId(), libTable );
|
||||
|
||||
if( libSymbol == nullptr )
|
||||
{
|
||||
std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_LIB_SYMBOL_ISSUES );
|
||||
ercItem->SetItems( symbol );
|
||||
msg.Printf( "Library symbol link \"%s\" cannot be found in symbol library table",
|
||||
symbol->GetLibId().GetUniStringLibId() );
|
||||
msg.Printf( "Symbol '%s' not found in symbol library '%s'",
|
||||
symbolName,
|
||||
libName );
|
||||
ercItem->SetErrorMessage( msg );
|
||||
|
||||
markers.emplace_back( new SCH_MARKER( ercItem, symbol->GetPosition() ) );
|
||||
break;
|
||||
}
|
||||
else
|
||||
|
||||
std::unique_ptr<LIB_PART> flattenedSymbol = libSymbol->Flatten();
|
||||
|
||||
if( *flattenedSymbol != *libSymbolInSchematic )
|
||||
{
|
||||
std::unique_ptr<LIB_PART> flattenedSymbol = libSymbol->Flatten();
|
||||
std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_LIB_SYMBOL_ISSUES );
|
||||
ercItem->SetItems( symbol );
|
||||
msg.Printf( "Symbol '%s' has been modified in library '%s'.",
|
||||
symbolName,
|
||||
libName );
|
||||
ercItem->SetErrorMessage( msg );
|
||||
|
||||
if( *flattenedSymbol != *libSymbolInSchematic )
|
||||
{
|
||||
std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_LIB_SYMBOL_ISSUES );
|
||||
ercItem->SetItems( symbol );
|
||||
msg.Printf( "Library symbol \"%s\" has been modified",
|
||||
symbol->GetLibId().GetUniStringLibId() );
|
||||
ercItem->SetErrorMessage( msg );
|
||||
|
||||
markers.emplace_back( new SCH_MARKER( ercItem, symbol->GetPosition() ) );
|
||||
}
|
||||
markers.emplace_back( new SCH_MARKER( ercItem, symbol->GetPosition() ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,6 @@
|
|||
#include <sch_view.h>
|
||||
#include <sch_painter.h>
|
||||
#include <settings/settings_manager.h>
|
||||
#include <gal/graphics_abstraction_layer.h>
|
||||
#include <confirm.h>
|
||||
#include <preview_items/selection_area.h>
|
||||
#include <class_library.h>
|
||||
|
@ -42,7 +41,6 @@
|
|||
#include <tool/tool_dispatcher.h>
|
||||
#include <tools/ee_actions.h>
|
||||
#include <tools/ee_selection_tool.h>
|
||||
#include <default_values.h> // For some default values
|
||||
|
||||
|
||||
LIB_PART* SchGetLibPart( const LIB_ID& aLibId, SYMBOL_LIB_TABLE* aLibTable, PART_LIB* aCacheLib,
|
||||
|
|
Loading…
Reference in New Issue