Fp editor: avoid having nil uuids when editing old footprints.
In Fpeditor, nil uuid has a special meaning and cannot be used as uuid in fp items. Fixes #8914 https://gitlab.com/kicad/code/kicad/issues/8914
This commit is contained in:
parent
c5e195bdff
commit
ac933d4e83
|
@ -221,6 +221,44 @@ FOOTPRINT::~FOOTPRINT()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool FOOTPRINT::FixUuids()
|
||||||
|
{
|
||||||
|
// replace null UUIDs if any by a valid uuid
|
||||||
|
std::vector< BOARD_ITEM* > item_list;
|
||||||
|
|
||||||
|
item_list.push_back( m_reference );
|
||||||
|
item_list.push_back( m_value );
|
||||||
|
|
||||||
|
for( PAD* pad : m_pads )
|
||||||
|
item_list.push_back( pad );
|
||||||
|
|
||||||
|
for( BOARD_ITEM* gr_item : m_drawings )
|
||||||
|
item_list.push_back( gr_item );
|
||||||
|
|
||||||
|
// Note: one cannot fix null UUIDs inside the group, but it should not happen
|
||||||
|
// because null uuids can be found in old footprints, therefore without group
|
||||||
|
for( PCB_GROUP* group : m_fp_groups )
|
||||||
|
item_list.push_back( group );
|
||||||
|
|
||||||
|
// Probably notneeded, because old fp do not have zones. But just in case.
|
||||||
|
for( FP_ZONE* zone : m_fp_zones )
|
||||||
|
item_list.push_back( zone );
|
||||||
|
|
||||||
|
bool changed = false;
|
||||||
|
|
||||||
|
for( BOARD_ITEM* item : item_list )
|
||||||
|
{
|
||||||
|
if( item->m_Uuid == niluuid )
|
||||||
|
{
|
||||||
|
const_cast<KIID&>( item->m_Uuid ) = KIID();
|
||||||
|
changed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return changed;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
FOOTPRINT& FOOTPRINT::operator=( FOOTPRINT&& aOther )
|
FOOTPRINT& FOOTPRINT::operator=( FOOTPRINT&& aOther )
|
||||||
{
|
{
|
||||||
BOARD_ITEM::operator=( aOther );
|
BOARD_ITEM::operator=( aOther );
|
||||||
|
|
|
@ -134,6 +134,15 @@ public:
|
||||||
*/
|
*/
|
||||||
void ClearAllNets();
|
void ClearAllNets();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Old footprints do not alway have a valid UUID (some can be set to null uuid)
|
||||||
|
* However null UUIDs, having a special meaning in editor, create issues when
|
||||||
|
* editing a footprint
|
||||||
|
* So all null uuids a re replaced by a valid uuid
|
||||||
|
* @return true if at least one uuid is changed, false if no change
|
||||||
|
*/
|
||||||
|
bool FixUuids();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the bounding box containing pads when the footprint is on the front side,
|
* Return the bounding box containing pads when the footprint is on the front side,
|
||||||
* orientation 0, position 0,0.
|
* orientation 0, position 0,0.
|
||||||
|
|
|
@ -461,6 +461,9 @@ void FOOTPRINT_EDIT_FRAME::AddFootprintToBoard( FOOTPRINT* aFootprint )
|
||||||
m_footprintNameWhenLoaded = aFootprint->GetFPID().GetLibItemName();
|
m_footprintNameWhenLoaded = aFootprint->GetFPID().GetLibItemName();
|
||||||
|
|
||||||
PCB_BASE_EDIT_FRAME::AddFootprintToBoard( aFootprint );
|
PCB_BASE_EDIT_FRAME::AddFootprintToBoard( aFootprint );
|
||||||
|
// Ensure item UUIDs are valide
|
||||||
|
// ("old" footprints can have null uuids that create issues in fp editor)
|
||||||
|
aFootprint->FixUuids();
|
||||||
|
|
||||||
if( IsCurrentFPFromBoard() )
|
if( IsCurrentFPFromBoard() )
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
*
|
*
|
||||||
* Copyright (C) 1992-2019 KiCad Developers, see AUTHORS.txt for contributors.
|
* Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
|
|
Loading…
Reference in New Issue