This commit is contained in:
Jeff Young 2024-04-06 10:00:26 +01:00
parent 1cbf6a1872
commit 968ca7c5c3
3 changed files with 23 additions and 41 deletions

View File

@ -68,7 +68,7 @@ std::vector<SEARCH_TERM> LIB_SYMBOL::GetSearchTerms()
}
void LIB_SYMBOL::GetChooserFields( std::map<wxString , wxString>& aColumnMap )
void LIB_SYMBOL::GetChooserFields( std::map<wxString, wxString>& aColumnMap )
{
for( LIB_ITEM& item : m_drawings[ LIB_FIELD_T ] )
{
@ -937,7 +937,6 @@ void LIB_SYMBOL::FixupDrawItems()
return a->GetBoundingBox().GetArea() > b->GetBoundingBox().GetArea();
} );
for( LIB_SHAPE* item : potential_top_items )
{
for( LIB_ITEM* bottom_item : bottom_items )
@ -1028,8 +1027,8 @@ int LIB_SYMBOL::GetPinCount()
{
std::vector<LIB_PIN*> pinList;
GetPins( pinList, 0, 1 ); // All units, but a single convert
return pinList.size();
GetPins( pinList, 0 /* all units */, 1 /* single body style */ );
return (int) pinList.size();
}
@ -1204,10 +1203,10 @@ void LIB_SYMBOL::SetFields( const std::vector<LIB_FIELD>& aFields )
{
deleteAllFields();
for( size_t ii = 0; ii < aFields.size(); ++ii )
for( const LIB_FIELD& src : aFields )
{
// drawings is a ptr_vector, new and copy an object on the heap.
LIB_FIELD* field = new LIB_FIELD( aFields[ ii ] );
LIB_FIELD* field = new LIB_FIELD( src );
field->SetParent( this );
m_drawings.push_back( field );
@ -1290,16 +1289,17 @@ const LIB_FIELD* LIB_SYMBOL::FindField( const wxString& aFieldName,
{
for( const LIB_ITEM& item : m_drawings[ LIB_FIELD_T ] )
{
const LIB_FIELD& field = static_cast<const LIB_FIELD&>( item );
if( aCaseInsensitive )
{
if( static_cast<const LIB_FIELD*>( &item )->GetCanonicalName().Upper()
== aFieldName.Upper() )
return static_cast<const LIB_FIELD*>( &item );
if( field.GetCanonicalName().Upper() == aFieldName.Upper() )
return &field;
}
else
{
if( static_cast<const LIB_FIELD*>( &item )->GetCanonicalName() == aFieldName )
return static_cast<const LIB_FIELD*>( &item );
if( field.GetCanonicalName() == aFieldName )
return &field;
}
}
@ -1387,9 +1387,7 @@ int LIB_SYMBOL::UpdateFieldOrdinals()
for( LIB_ITEM& item : m_drawings[ LIB_FIELD_T ] )
{
LIB_FIELD* field = dynamic_cast<LIB_FIELD*>( &item );
wxCHECK2( field, continue );
LIB_FIELD* field = static_cast<LIB_FIELD*>( &item );
// Mandatory fields were already resolved always have the same ordinal values.
if( field->IsMandatory() )
@ -1605,7 +1603,7 @@ void LIB_SYMBOL::SetHasAlternateBodyStyle( bool aHasAlternate, bool aDuplicatePi
{
if( aDuplicatePins )
{
std::vector< LIB_ITEM* > tmp; // Temporarily store the duplicated pins here.
std::vector<LIB_ITEM*> tmp; // Temporarily store the duplicated pins here.
for( LIB_ITEM& item : m_drawings )
{
@ -1615,21 +1613,20 @@ void LIB_SYMBOL::SetHasAlternateBodyStyle( bool aHasAlternate, bool aDuplicatePi
if( item.m_bodyStyle == 1 )
{
LIB_ITEM* newItem = (LIB_ITEM*) item.Duplicate();
LIB_ITEM* newItem = static_cast<LIB_ITEM*>( item.Duplicate() );
newItem->m_bodyStyle = 2;
tmp.push_back( newItem );
}
}
// Transfer the new pins to the LIB_SYMBOL.
for( unsigned i = 0; i < tmp.size(); i++ )
m_drawings.push_back( tmp[i] );
for( LIB_ITEM* item : tmp )
m_drawings.push_back( item );
}
}
else
{
// Delete converted shape items because the converted shape does
// not exist
// Delete converted shape items because the converted shape does not exist
LIB_ITEMS_CONTAINER::ITERATOR i = m_drawings.begin();
while( i != m_drawings.end() )

View File

@ -81,12 +81,6 @@ SCH_ITEM& SCH_ITEM::operator=( const SCH_ITEM& aItem )
SCH_ITEM::~SCH_ITEM()
{
// Do not let the connections container go out of scope with any objects or they
// will be deleted by the container will cause the Eeschema to crash. These objects
// are owned by the sheet object container.
if( !m_connections.empty() )
m_connections.clear();
for( const auto& it : m_connection_map )
delete it.second;
}

View File

@ -388,14 +388,6 @@ public:
*/
virtual std::vector<VECTOR2I> GetConnectionPoints() const { return {}; }
/**
* Clears all of the connection items from the list.
*
* The vector release method is used to prevent the item pointers from being deleted.
* Do not use the vector erase method on the connection list.
*/
void ClearConnections() { m_connections.clear(); }
/**
* Test the item to see if it is connected to \a aPoint.
*
@ -578,10 +570,9 @@ private:
protected:
SCH_LAYER_ID m_layer;
EDA_ITEMS m_connections; // List of items connected to this item.
FIELDS_AUTOPLACED m_fieldsAutoplaced; // indicates status of field autoplacement
VECTOR2I m_storedPos; // a temporary variable used in some move commands
// to store a initial pos of the item or mouse cursor
VECTOR2I m_storedPos; // temp variable used in some move commands to store
// an initial position of the item or mouse cursor
/// Store pointers to other items that are connected to this one, per sheet.
std::map<SCH_SHEET_PATH, SCH_ITEM_SET, SHEET_PATH_CMP> m_connected_items;