eeschema: Prevent invalid '0' element in components
In the component, an m_unit/m_convert element is 1-indexed as opposed to
the library where they are 0-indexed. The 0-index in the library is
reserved for those elements that are shared across all conversion/unit
whereas it is invalid for the component.
Fixes: lp:1824764
* https://bugs.launchpad.net/kicad/+bug/1824764
(cherry picked from commit c4be74a9d0
)
This commit is contained in:
parent
c135158364
commit
1437e56b72
|
@ -910,7 +910,7 @@ bool LIB_PART::HasConversion() const
|
|||
{
|
||||
for( const LIB_ITEM& item : m_drawings )
|
||||
{
|
||||
if( item.m_Convert > 1 )
|
||||
if( item.m_Convert > LIB_ITEM::LIB_CONVERT::BASE )
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -175,7 +175,7 @@ bool DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::TransferDataToWindow()
|
|||
|
||||
if( m_part != nullptr && m_part->HasConversion() )
|
||||
{
|
||||
if( m_cmp->GetConvert() > 1 )
|
||||
if( m_cmp->GetConvert() > LIB_ITEM::LIB_CONVERT::BASE )
|
||||
m_cbAlternateSymbol->SetValue( true );
|
||||
}
|
||||
else
|
||||
|
@ -252,7 +252,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnBrowseLibrary( wxCommandEvent& event
|
|||
for( int ii = 1; ii <= entry->GetUnitCount(); ii++ )
|
||||
m_unitChoice->Append( LIB_PART::SubReference( ii, false ) );
|
||||
|
||||
if( unit < 0 || unit >= (int)m_unitChoice->GetCount() )
|
||||
if( unit < 0 || static_cast<unsigned>( unit ) >= m_unitChoice->GetCount() )
|
||||
unit = 0;
|
||||
|
||||
m_unitChoice->SetSelection( unit );
|
||||
|
@ -405,15 +405,15 @@ bool DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::TransferDataFromWindow()
|
|||
m_cmp->SetLibId( id, Prj().SchSymbolLibTable(), Prj().SchLibs()->GetCacheLibrary() );
|
||||
|
||||
// For symbols with multiple shapes (De Morgan representation) Set the selected shape:
|
||||
int conversion = m_cbAlternateSymbol->IsEnabled()
|
||||
? m_cbAlternateSymbol->GetValue()
|
||||
: 0;
|
||||
m_cmp->SetConvert( conversion );
|
||||
if( m_cbAlternateSymbol->IsEnabled() && m_cbAlternateSymbol->GetValue() )
|
||||
m_cmp->SetConvert( LIB_ITEM::LIB_CONVERT::DEMORGAN );
|
||||
else
|
||||
m_cmp->SetConvert( LIB_ITEM::LIB_CONVERT::BASE );
|
||||
|
||||
//Set the part selection in multiple part per package
|
||||
int unit_selection = m_unitChoice->IsEnabled()
|
||||
? m_unitChoice->GetSelection() + 1
|
||||
: 0;
|
||||
: 1;
|
||||
m_cmp->SetUnitSelection( &GetParent()->GetCurrentSheet(), unit_selection );
|
||||
m_cmp->SetUnit( unit_selection );
|
||||
|
||||
|
|
|
@ -373,14 +373,14 @@ void SCH_EDIT_FRAME::ConvertPart( SCH_COMPONENT* aComponent )
|
|||
|
||||
aComponent->SetConvert( aComponent->GetConvert() + 1 );
|
||||
|
||||
// ensure m_Convert = 0, 1 or 2
|
||||
// 0 and 1 = shape 1 = not converted
|
||||
// ensure m_Convert = 1 or 2
|
||||
// 1 = shape 1 = not converted
|
||||
// 2 = shape 2 = first converted shape
|
||||
// > 2 is not used but could be used for more shapes
|
||||
// like multiple shapes for a programmable component
|
||||
// When m_Convert = val max, return to the first shape
|
||||
if( aComponent->GetConvert() > 2 )
|
||||
aComponent->SetConvert( 1 );
|
||||
if( aComponent->GetConvert() > LIB_ITEM::LIB_CONVERT::DEMORGAN )
|
||||
aComponent->SetConvert( LIB_ITEM::LIB_CONVERT::BASE );
|
||||
|
||||
// The alternate symbol may cause a change in the connection status so test the
|
||||
// connections so the connection indicators are drawn correctly.
|
||||
|
|
|
@ -66,11 +66,9 @@ void LIB_ITEM::GetMsgPanelInfo( EDA_UNITS_T aUnits, MSG_PANEL_ITEMS& aList )
|
|||
|
||||
aList.push_back( MSG_PANEL_ITEM( _( "Unit" ), msg, BROWN ) );
|
||||
|
||||
if( m_Convert == 0 )
|
||||
msg = _( "All" );
|
||||
else if( m_Convert == 1 )
|
||||
if( m_Convert == LIB_ITEM::LIB_CONVERT::BASE )
|
||||
msg = _( "no" );
|
||||
else if( m_Convert == 2 )
|
||||
else if( m_Convert == LIB_ITEM::LIB_CONVERT::DEMORGAN )
|
||||
msg = _( "yes" );
|
||||
else
|
||||
msg = wxT( "?" );
|
||||
|
|
|
@ -120,6 +120,10 @@ public:
|
|||
|
||||
virtual ~LIB_ITEM() { }
|
||||
|
||||
|
||||
// Define the enums for basic
|
||||
enum LIB_CONVERT : int { BASE = 1, DEMORGAN = 2 };
|
||||
|
||||
/**
|
||||
* Provide a user-consumable name of the object type. Perform localization when
|
||||
* called so that run-time language selection works.
|
||||
|
|
|
@ -194,8 +194,8 @@ SCH_COMPONENT::SCH_COMPONENT( const SCH_COMPONENT& aComponent ) :
|
|||
void SCH_COMPONENT::Init( const wxPoint& pos )
|
||||
{
|
||||
m_Pos = pos;
|
||||
m_unit = 0; // In multi unit chip - which unit to draw.
|
||||
m_convert = 0; // De Morgan Handling
|
||||
m_unit = 1; // In multi unit chip - which unit to draw.
|
||||
m_convert = LIB_ITEM::LIB_CONVERT::BASE; // De Morgan Handling
|
||||
|
||||
// The rotation/mirror transformation matrix. pos normal
|
||||
m_transform = TRANSFORM();
|
||||
|
|
|
@ -224,7 +224,7 @@ LIB_VIEW_FRAME::~LIB_VIEW_FRAME()
|
|||
void LIB_VIEW_FRAME::SetUnitAndConvert( int aUnit, int aConvert )
|
||||
{
|
||||
m_unit = aUnit > 0 ? aUnit : 1;
|
||||
m_convert = aConvert > 0 ? aConvert : 1;
|
||||
m_convert = aConvert > 0 ? aConvert : LIB_ITEM::LIB_CONVERT::BASE;
|
||||
m_selection_changed = false;
|
||||
|
||||
// Update canvas
|
||||
|
@ -542,7 +542,7 @@ bool LIB_VIEW_FRAME::ReCreateListLib()
|
|||
m_libraryName = libs[0];
|
||||
m_entryName = wxEmptyString;
|
||||
m_unit = 1;
|
||||
m_convert = 1;
|
||||
m_convert = LIB_ITEM::LIB_CONVERT::BASE;
|
||||
}
|
||||
|
||||
bool cmp_changed = ReCreateListCmp();
|
||||
|
@ -573,7 +573,7 @@ bool LIB_VIEW_FRAME::ReCreateListCmp()
|
|||
{
|
||||
m_libraryName = wxEmptyString;
|
||||
m_entryName = wxEmptyString;
|
||||
m_convert = 1;
|
||||
m_convert = LIB_ITEM::LIB_CONVERT::BASE;
|
||||
m_unit = 1;
|
||||
return true;
|
||||
}
|
||||
|
@ -587,7 +587,7 @@ bool LIB_VIEW_FRAME::ReCreateListCmp()
|
|||
{
|
||||
// Select the first library entry when the previous entry name does not exist in
|
||||
// the current library.
|
||||
m_convert = 1;
|
||||
m_convert = LIB_ITEM::LIB_CONVERT::BASE;
|
||||
m_unit = 1;
|
||||
index = 0;
|
||||
changed = true;
|
||||
|
@ -661,7 +661,7 @@ void LIB_VIEW_FRAME::SetSelectedComponent( const wxString& aComponentName )
|
|||
if( m_selection_changed )
|
||||
{
|
||||
m_unit = 1;
|
||||
m_convert = 1;
|
||||
m_convert = LIB_ITEM::LIB_CONVERT::BASE;
|
||||
m_selection_changed = false;
|
||||
}
|
||||
|
||||
|
|
|
@ -144,11 +144,11 @@ void LIB_VIEW_FRAME::onSelectSymbolBodyStyle( wxCommandEvent& aEvent )
|
|||
{
|
||||
default:
|
||||
case ID_LIBVIEW_DE_MORGAN_NORMAL_BUTT:
|
||||
m_convert = 1;
|
||||
m_convert = LIB_ITEM::LIB_CONVERT::BASE;
|
||||
break;
|
||||
|
||||
case ID_LIBVIEW_DE_MORGAN_CONVERT_BUTT:
|
||||
m_convert = 2;
|
||||
m_convert = LIB_ITEM::LIB_CONVERT::DEMORGAN;
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue