Pcbnew: fix missing connectivity update when adding an item.

Skipping connectivity update when adding an item is possible only when loading a file
Fixes #10879
https://gitlab.com/kicad/code/kicad/issues/10879
This commit is contained in:
jean-pierre charras 2022-02-18 13:23:50 +01:00
parent 8ee81e0fc4
commit 2fddc9daf3
6 changed files with 38 additions and 29 deletions

View File

@ -671,7 +671,7 @@ void BOARD::CacheTriangulation( PROGRESS_REPORTER* aReporter, const std::vector<
} }
void BOARD::Add( BOARD_ITEM* aBoardItem, ADD_MODE aMode ) void BOARD::Add( BOARD_ITEM* aBoardItem, ADD_MODE aMode, bool aSkipConnectivity )
{ {
if( aBoardItem == nullptr ) if( aBoardItem == nullptr )
{ {
@ -757,9 +757,11 @@ void BOARD::Add( BOARD_ITEM* aBoardItem, ADD_MODE aMode )
aBoardItem->SetParent( this ); aBoardItem->SetParent( this );
aBoardItem->ClearEditFlags(); aBoardItem->ClearEditFlags();
if( !aSkipConnectivity )
m_connectivity->Add( aBoardItem );
if( aMode != ADD_MODE::BULK_INSERT && aMode != ADD_MODE::BULK_APPEND ) if( aMode != ADD_MODE::BULK_INSERT && aMode != ADD_MODE::BULK_APPEND )
{ {
m_connectivity->Add( aBoardItem );
InvokeListeners( &BOARD_LISTENER::OnBoardItemAdded, *this, aBoardItem ); InvokeListeners( &BOARD_LISTENER::OnBoardItemAdded, *this, aBoardItem );
} }
} }

View File

@ -2,7 +2,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) 2007 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com * Copyright (C) 2007 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 1992-2022 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
@ -292,8 +292,11 @@ public:
void SetGenerator( const wxString& aGenerator ) { m_generator = aGenerator; } void SetGenerator( const wxString& aGenerator ) { m_generator = aGenerator; }
const wxString& GetGenerator() const { return m_generator; } const wxString& GetGenerator() const { return m_generator; }
void Add( BOARD_ITEM* aItem, ADD_MODE aMode = ADD_MODE::INSERT ) override; ///< @copydoc BOARD_ITEM_CONTAINER::Add()
void Add( BOARD_ITEM* aItem, ADD_MODE aMode = ADD_MODE::INSERT,
bool aSkipConnectivity = false ) override;
///< @copydoc BOARD_ITEM_CONTAINER::Remove()
void Remove( BOARD_ITEM* aBoardItem, REMOVE_MODE aMode = REMOVE_MODE::NORMAL ) override; void Remove( BOARD_ITEM* aBoardItem, REMOVE_MODE aMode = REMOVE_MODE::NORMAL ) override;
/** /**

View File

@ -2,7 +2,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) 2016 CERN * Copyright (C) 2016 CERN
* Copyright (C) 2016-2017 KiCad Developers, see change_log.txt for contributors. * Copyright (C) 2016-2022 KiCad Developers, see AUTHORS.txt for contributors.
* *
* @author Maciej Suminski <maciej.suminski@cern.ch> * @author Maciej Suminski <maciej.suminski@cern.ch>
* *
@ -60,8 +60,11 @@ public:
/** /**
* @brief Adds an item to the container. * @brief Adds an item to the container.
* @param aMode decides whether the item is added in the beginning or at the end of the list. * @param aMode decides whether the item is added in the beginning or at the end of the list.
* @param aSkipConnectivity skip connectivity update (usefull for file loading, when
* the connectivity is updated after end of loading).
*/ */
virtual void Add( BOARD_ITEM* aItem, ADD_MODE aMode = ADD_MODE::INSERT ) = 0; virtual void Add( BOARD_ITEM* aItem, ADD_MODE aMode = ADD_MODE::INSERT,
bool aSkipConnectivity = false ) = 0;
/** /**
* @brief Removes an item from the container. * @brief Removes an item from the container.

View File

@ -496,7 +496,7 @@ void FOOTPRINT::ClearAllNets()
} }
void FOOTPRINT::Add( BOARD_ITEM* aBoardItem, ADD_MODE aMode ) void FOOTPRINT::Add( BOARD_ITEM* aBoardItem, ADD_MODE aMode, bool aSkipConnectivity )
{ {
switch( aBoardItem->Type() ) switch( aBoardItem->Type() )
{ {

View File

@ -2,7 +2,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) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 1992-2022 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
@ -126,7 +126,8 @@ public:
void SetPrivateLayers( LSET aLayers ) { m_privateLayers = aLayers; } void SetPrivateLayers( LSET aLayers ) { m_privateLayers = aLayers; }
///< @copydoc BOARD_ITEM_CONTAINER::Add() ///< @copydoc BOARD_ITEM_CONTAINER::Add()
void Add( BOARD_ITEM* aItem, ADD_MODE aMode = ADD_MODE::INSERT ) override; void Add( BOARD_ITEM* aItem, ADD_MODE aMode = ADD_MODE::INSERT,
bool aSkipConnectivity = false ) override;
///< @copydoc BOARD_ITEM_CONTAINER::Remove() ///< @copydoc BOARD_ITEM_CONTAINER::Remove()
void Remove( BOARD_ITEM* aItem, REMOVE_MODE aMode = REMOVE_MODE::NORMAL ) override; void Remove( BOARD_ITEM* aItem, REMOVE_MODE aMode = REMOVE_MODE::NORMAL ) override;

View File

@ -843,44 +843,44 @@ BOARD* PCB_PARSER::parseBOARD_unchecked()
case T_gr_circle: case T_gr_circle:
case T_gr_rect: case T_gr_rect:
item = parsePCB_SHAPE(); item = parsePCB_SHAPE();
m_board->Add( item, ADD_MODE::BULK_APPEND ); m_board->Add( item, ADD_MODE::BULK_APPEND, true );
bulkAddedItems.push_back( item ); bulkAddedItems.push_back( item );
break; break;
case T_gr_text: case T_gr_text:
item = parsePCB_TEXT(); item = parsePCB_TEXT();
m_board->Add( item, ADD_MODE::BULK_APPEND ); m_board->Add( item, ADD_MODE::BULK_APPEND, true );
bulkAddedItems.push_back( item ); bulkAddedItems.push_back( item );
break; break;
case T_gr_text_box: case T_gr_text_box:
item = parsePCB_TEXTBOX(); item = parsePCB_TEXTBOX();
m_board->Add( item, ADD_MODE::BULK_APPEND ); m_board->Add( item, ADD_MODE::BULK_APPEND, true );
bulkAddedItems.push_back( item ); bulkAddedItems.push_back( item );
break; break;
case T_dimension: case T_dimension:
item = parseDIMENSION( m_board, false ); item = parseDIMENSION( m_board, false );
m_board->Add( item, ADD_MODE::BULK_APPEND ); m_board->Add( item, ADD_MODE::BULK_APPEND, true );
bulkAddedItems.push_back( item ); bulkAddedItems.push_back( item );
break; break;
case T_module: // legacy token case T_module: // legacy token
case T_footprint: case T_footprint:
item = parseFOOTPRINT(); item = parseFOOTPRINT();
m_board->Add( item, ADD_MODE::BULK_APPEND ); m_board->Add( item, ADD_MODE::BULK_APPEND, true );
bulkAddedItems.push_back( item ); bulkAddedItems.push_back( item );
break; break;
case T_segment: case T_segment:
item = parsePCB_TRACK(); item = parsePCB_TRACK();
m_board->Add( item, ADD_MODE::BULK_APPEND ); m_board->Add( item, ADD_MODE::BULK_APPEND, true );
bulkAddedItems.push_back( item ); bulkAddedItems.push_back( item );
break; break;
case T_arc: case T_arc:
item = parseARC(); item = parseARC();
m_board->Add( item, ADD_MODE::BULK_APPEND ); m_board->Add( item, ADD_MODE::BULK_APPEND, true );
bulkAddedItems.push_back( item ); bulkAddedItems.push_back( item );
break; break;
@ -890,19 +890,19 @@ BOARD* PCB_PARSER::parseBOARD_unchecked()
case T_via: case T_via:
item = parsePCB_VIA(); item = parsePCB_VIA();
m_board->Add( item, ADD_MODE::BULK_APPEND ); m_board->Add( item, ADD_MODE::BULK_APPEND, true );
bulkAddedItems.push_back( item ); bulkAddedItems.push_back( item );
break; break;
case T_zone: case T_zone:
item = parseZONE( m_board ); item = parseZONE( m_board );
m_board->Add( item, ADD_MODE::BULK_APPEND ); m_board->Add( item, ADD_MODE::BULK_APPEND, true );
bulkAddedItems.push_back( item ); bulkAddedItems.push_back( item );
break; break;
case T_target: case T_target:
item = parsePCB_TARGET(); item = parsePCB_TARGET();
m_board->Add( item, ADD_MODE::BULK_APPEND ); m_board->Add( item, ADD_MODE::BULK_APPEND, true );
bulkAddedItems.push_back( item ); bulkAddedItems.push_back( item );
break; break;
@ -1052,9 +1052,9 @@ void PCB_PARSER::resolveGroups( BOARD_ITEM* aParent )
group->SetLocked( true ); group->SetLocked( true );
if( aGrp.parent->Type() == PCB_FOOTPRINT_T ) if( aGrp.parent->Type() == PCB_FOOTPRINT_T )
static_cast<FOOTPRINT*>( aGrp.parent )->Add( group ); static_cast<FOOTPRINT*>( aGrp.parent )->Add( group, ADD_MODE::INSERT, true );
else else
static_cast<BOARD*>( aGrp.parent )->Add( group ); static_cast<BOARD*>( aGrp.parent )->Add( group, ADD_MODE::INSERT, true );
} }
wxString error; wxString error;
@ -2354,7 +2354,7 @@ void PCB_PARSER::parseNETINFO_ITEM()
if( netCode > NETINFO_LIST::UNCONNECTED || !m_board->FindNet( NETINFO_LIST::UNCONNECTED ) ) if( netCode > NETINFO_LIST::UNCONNECTED || !m_board->FindNet( NETINFO_LIST::UNCONNECTED ) )
{ {
NETINFO_ITEM* net = new NETINFO_ITEM( m_board, name, netCode ); NETINFO_ITEM* net = new NETINFO_ITEM( m_board, name, netCode );
m_board->Add( net ); m_board->Add( net, ADD_MODE::INSERT, true );
// Store the new code mapping // Store the new code mapping
pushValueIntoMap( netCode, net->GetNetCode() ); pushValueIntoMap( netCode, net->GetNetCode() );
@ -3721,7 +3721,7 @@ FOOTPRINT* PCB_PARSER::parseFOOTPRINT_unchecked( wxArrayString* aInitialComments
break; break;
default: default:
footprint->Add( text, ADD_MODE::APPEND ); footprint->Add( text, ADD_MODE::APPEND, true );
} }
break; break;
@ -3732,7 +3732,7 @@ FOOTPRINT* PCB_PARSER::parseFOOTPRINT_unchecked( wxArrayString* aInitialComments
FP_TEXTBOX* textbox = parseFP_TEXTBOX(); FP_TEXTBOX* textbox = parseFP_TEXTBOX();
textbox->SetParent( footprint.get() ); textbox->SetParent( footprint.get() );
textbox->SetDrawCoord(); textbox->SetDrawCoord();
footprint->Add( textbox, ADD_MODE::APPEND ); footprint->Add( textbox, ADD_MODE::APPEND, true );
break; break;
} }
@ -3746,14 +3746,14 @@ FOOTPRINT* PCB_PARSER::parseFOOTPRINT_unchecked( wxArrayString* aInitialComments
FP_SHAPE* shape = parseFP_SHAPE(); FP_SHAPE* shape = parseFP_SHAPE();
shape->SetParent( footprint.get() ); shape->SetParent( footprint.get() );
shape->SetDrawCoord(); shape->SetDrawCoord();
footprint->Add( shape, ADD_MODE::APPEND ); footprint->Add( shape, ADD_MODE::APPEND, true );
break; break;
} }
case T_dimension: case T_dimension:
{ {
PCB_DIMENSION_BASE* dimension = parseDIMENSION( footprint.get(), true ); PCB_DIMENSION_BASE* dimension = parseDIMENSION( footprint.get(), true );
footprint->Add( dimension, ADD_MODE::APPEND ); footprint->Add( dimension, ADD_MODE::APPEND, true );
break; break;
} }
@ -3764,7 +3764,7 @@ FOOTPRINT* PCB_PARSER::parseFOOTPRINT_unchecked( wxArrayString* aInitialComments
RotatePoint( pt, footprint->GetOrientation() ); RotatePoint( pt, footprint->GetOrientation() );
pad->SetPosition( pt + footprint->GetPosition() ); pad->SetPosition( pt + footprint->GetPosition() );
footprint->Add( pad, ADD_MODE::APPEND ); footprint->Add( pad, ADD_MODE::APPEND, true );
break; break;
} }
@ -3779,7 +3779,7 @@ FOOTPRINT* PCB_PARSER::parseFOOTPRINT_unchecked( wxArrayString* aInitialComments
case T_zone: case T_zone:
{ {
ZONE* zone = parseZONE( footprint.get() ); ZONE* zone = parseZONE( footprint.get() );
footprint->Add( zone, ADD_MODE::APPEND ); footprint->Add( zone, ADD_MODE::APPEND, true );
break; break;
} }
@ -5872,7 +5872,7 @@ ZONE* PCB_PARSER::parseZONE( BOARD_ITEM_CONTAINER* aParent )
{ {
int newnetcode = m_board->GetNetCount(); int newnetcode = m_board->GetNetCount();
net = new NETINFO_ITEM( m_board, netnameFromfile, newnetcode ); net = new NETINFO_ITEM( m_board, netnameFromfile, newnetcode );
m_board->Add( net ); m_board->Add( net, ADD_MODE::INSERT, true );
// Store the new code mapping // Store the new code mapping
pushValueIntoMap( newnetcode, net->GetNetCode() ); pushValueIntoMap( newnetcode, net->GetNetCode() );