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

This commit is contained in:
charras 2008-10-18 13:42:21 +00:00
parent 324f574439
commit 53b0165b3e
1 changed files with 34 additions and 38 deletions

View File

@ -50,6 +50,7 @@ SCH_COMPONENT::SCH_COMPONENT( const wxPoint& aPos, SCH_ITEM* aParent ) :
field.SetLayer( LAYER_REFERENCEPART ); field.SetLayer( LAYER_REFERENCEPART );
else if( i==VALUE ) else if( i==VALUE )
field.SetLayer( LAYER_VALUEPART ); field.SetLayer( LAYER_VALUEPART );
// else keep LAYER_FIELDS from SCH_CMP_FIELD constructor // else keep LAYER_FIELDS from SCH_CMP_FIELD constructor
// SCH_CMP_FIELD's implicitly created copy constructor is called in here // 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" ) ); m_PrefixString = wxString( _( "U" ) );
} }
/** /**
* Function AddHierarchicalReference * Function AddHierarchicalReference
* adds a full hierachical reference (path + local reference) * 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] ); EXCHG( m_Transform[1][1], copyitem->m_Transform[1][1] );
m_Fields.swap( copyitem->m_Fields ); // std::vector's swap() 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. // UpdateAllScreenReferences for the active sheet.
// But this call cannot made here. // But this call cannot made here.
m_Fields[REFERENCE].m_Text = defRef; //for drawing. m_Fields[REFERENCE].m_Text = defRef; //for drawing.
} }
@ -495,27 +505,14 @@ void SCH_COMPONENT::ClearAnnotation( DrawSheetPath* aSheet )
SCH_COMPONENT* SCH_COMPONENT::GenCopy() 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 ); SCH_COMPONENT* new_item = new SCH_COMPONENT( *this );
// Reset chain pointers:
#endif 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; return new_item;
} }
@ -785,7 +782,6 @@ void SCH_COMPONENT::Show( int nestLevel, std::ostream& os )
#endif #endif
/****************************************/ /****************************************/
bool SCH_COMPONENT::Save( FILE* f ) const bool SCH_COMPONENT::Save( FILE* f ) const
/****************************************/ /****************************************/