Browse Source

eeschema: restore right value for m_Parent field member in SCH_COMPONENT::GenCopy() and SCH_COMPONENT::SwapData()

pull/1/head
charras 17 years ago
parent
commit
53b0165b3e
  1. 42
      eeschema/component_class.cpp

42
eeschema/component_class.cpp

@ -50,6 +50,7 @@ SCH_COMPONENT::SCH_COMPONENT( const wxPoint& aPos, SCH_ITEM* aParent ) :
field.SetLayer( LAYER_REFERENCEPART );
else if( i==VALUE )
field.SetLayer( LAYER_VALUEPART );
// else keep LAYER_FIELDS from SCH_CMP_FIELD constructor
// SCH_CMP_FIELD's implicitly created copy constructor is called in here
@ -59,7 +60,6 @@ SCH_COMPONENT::SCH_COMPONENT( const wxPoint& aPos, SCH_ITEM* aParent ) :
m_PrefixString = wxString( _( "U" ) );
}
/**
* Function AddHierarchicalReference
* adds a full hierachical reference (path + local reference)
@ -399,6 +399,17 @@ void SCH_COMPONENT::SwapData( SCH_COMPONENT* copyitem )
EXCHG( m_Transform[1][1], copyitem->m_Transform[1][1] );
m_Fields.swap( copyitem->m_Fields ); // std::vector's swap()
// Reparent items after copying data (after swap() m_Pareny member does not points the right parent):
for( int ii = 0; ii < copyitem->GetFieldCount(); ++ii )
{
copyitem->GetField(ii)->m_Parent = copyitem;
}
for( int ii = 0; ii < GetFieldCount(); ++ii )
{
GetField(ii)->m_Parent = this;
}
}
@ -487,7 +498,6 @@ void SCH_COMPONENT::ClearAnnotation( DrawSheetPath* aSheet )
// UpdateAllScreenReferences for the active sheet.
// But this call cannot made here.
m_Fields[REFERENCE].m_Text = defRef; //for drawing.
}
@ -495,27 +505,14 @@ void SCH_COMPONENT::ClearAnnotation( DrawSheetPath* aSheet )
SCH_COMPONENT* SCH_COMPONENT::GenCopy()
/**************************************************************/
{
#if 0
SCH_COMPONENT* new_item = new SCH_COMPONENT( m_Pos );
new_item->m_Multi = m_Multi;
new_item->m_ChipName = m_ChipName;
new_item->m_PrefixString = m_PrefixString;
new_item->m_Convert = m_Convert;
new_item->m_Transform[0][0] = m_Transform[0][0];
new_item->m_Transform[0][1] = m_Transform[0][1];
new_item->m_Transform[1][0] = m_Transform[1][0];
new_item->m_Transform[1][1] = m_Transform[1][1];
new_item->m_TimeStamp = m_TimeStamp;
new_item->m_Fields = m_Fields;
#else
SCH_COMPONENT* new_item = new SCH_COMPONENT( *this );
#endif
// Reset chain pointers:
new_item->Pback = new_item->Pnext = new_item->m_Son = NULL;
// Reparent items after copy:
for( int ii = 0; ii < new_item->GetFieldCount(); ++ii )
{
new_item->GetField(ii)->m_Parent = new_item;
}
return new_item;
}
@ -785,7 +782,6 @@ void SCH_COMPONENT::Show( int nestLevel, std::ostream& os )
#endif
/****************************************/
bool SCH_COMPONENT::Save( FILE* f ) const
/****************************************/

Loading…
Cancel
Save