Eeschema: Add protections to eeschema rtree

Prevents items from being mistakenly added to the tree that should not
be tracked in the tree.
This commit is contained in:
Seth Hillbrand 2020-01-25 09:32:05 -08:00
parent 84a697060f
commit b8920a9f5a
2 changed files with 12 additions and 9 deletions

View File

@ -173,10 +173,13 @@ void SCH_SCREEN::DecRefCount()
void SCH_SCREEN::Append( SCH_ITEM* aItem )
{
if( aItem->Type() != SCH_SHEET_PIN_T && aItem->Type() != SCH_FIELD_T )
{
m_rtree.insert( aItem );
--m_modification_sync;
}
}
void SCH_SCREEN::Append( SCH_SCREEN* aScreen )
@ -186,9 +189,8 @@ void SCH_SCREEN::Append( SCH_SCREEN* aScreen )
// No need to descend the hierarchy. Once the top level screen is copied, all of it's
// children are copied as well.
for( auto aItem : aScreen->m_rtree )
m_rtree.insert( aItem );
Append( aItem );
--m_modification_sync;
aScreen->Clear( false );
}
@ -227,14 +229,14 @@ void SCH_SCREEN::FreeDrawList()
void SCH_SCREEN::Update( SCH_ITEM* aItem )
{
Remove( aItem );
if( Remove( aItem ) )
Append( aItem );
}
void SCH_SCREEN::Remove( SCH_ITEM* aItem )
bool SCH_SCREEN::Remove( SCH_ITEM* aItem )
{
m_rtree.remove( aItem );
return m_rtree.remove( aItem );
}

View File

@ -260,8 +260,9 @@ public:
*
* @note The removed item is not deleted. It is only unlinked from the item list.
* @param aItem Item to be removed from schematic.
* @return True if we successfully removed the item
*/
void Remove( SCH_ITEM* aItem );
bool Remove( SCH_ITEM* aItem );
/**
* Updates \a aItem's bounding box in the tree