From 8bd77c4fe7e9c62bb921f91dadbbf6971fef0122 Mon Sep 17 00:00:00 2001 From: Ian McInerney Date: Wed, 16 Sep 2020 01:59:12 +0100 Subject: [PATCH] Rename the ITEM_SET types to be descriptive of their contents Now that we have one set type for BOARD_ITEMs and another for SCH_ITEMs it is better to explictly say if they are board or schematic sets. --- eeschema/sch_item.cpp | 2 +- eeschema/sch_item.h | 6 +++--- include/class_pcb_group.h | 6 +++--- pcbnew/class_board.cpp | 12 ++++++------ 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/eeschema/sch_item.cpp b/eeschema/sch_item.cpp index ca8569a5b0..c3cb73d0a7 100644 --- a/eeschema/sch_item.cpp +++ b/eeschema/sch_item.cpp @@ -175,7 +175,7 @@ NETCLASSPTR SCH_ITEM::NetClass() const } -ITEM_SET& SCH_ITEM::ConnectedItems( const SCH_SHEET_PATH& aSheet ) +SCH_ITEM_SET& SCH_ITEM::ConnectedItems( const SCH_SHEET_PATH& aSheet ) { return m_connected_items[ aSheet ]; } diff --git a/eeschema/sch_item.h b/eeschema/sch_item.h index 55c3e4c803..801ad9f6b2 100644 --- a/eeschema/sch_item.h +++ b/eeschema/sch_item.h @@ -144,7 +144,7 @@ public: }; -typedef std::unordered_set ITEM_SET; +typedef std::unordered_set SCH_ITEM_SET; /** @@ -203,7 +203,7 @@ protected: // to store a initial pos of the item or mouse cursor /// Stores pointers to other items that are connected to this one, per sheet - std::unordered_map m_connected_items; + std::unordered_map m_connected_items; /// Stores connectivity information, per sheet std::unordered_map m_connection_map; @@ -411,7 +411,7 @@ public: /** * Retrieves the set of items connected to this item on the given sheet */ - ITEM_SET& ConnectedItems( const SCH_SHEET_PATH& aPath ); + SCH_ITEM_SET& ConnectedItems( const SCH_SHEET_PATH& aPath ); /** * Adds a connection link between this item and another diff --git a/include/class_pcb_group.h b/include/class_pcb_group.h index b52bec85e2..fc2ade90aa 100644 --- a/include/class_pcb_group.h +++ b/include/class_pcb_group.h @@ -45,7 +45,7 @@ namespace KIGFX class VIEW; } -typedef std::unordered_set ITEM_SET; +typedef std::unordered_set BOARD_ITEM_SET; /** * PCB_GROUP is a set of BOARD_ITEMs (i.e., without duplicates) @@ -65,7 +65,7 @@ public: return m_name; } - const ITEM_SET& GetItems() const + const BOARD_ITEM_SET& GetItems() const { return m_items; } @@ -202,7 +202,7 @@ public: private: // Members of the group - ITEM_SET m_items; + BOARD_ITEM_SET m_items; // Optional group name wxString m_name; diff --git a/pcbnew/class_board.cpp b/pcbnew/class_board.cpp index 7d0a78b343..074d78dfdb 100644 --- a/pcbnew/class_board.cpp +++ b/pcbnew/class_board.cpp @@ -2185,10 +2185,10 @@ BOARD::GroupLegalOpsField BOARD::GroupLegalOps( const PCBNEW_SELECTION& selectio void BOARD::GroupRemoveItems( const PCBNEW_SELECTION& selection, BOARD_COMMIT* commit ) { std::unordered_set emptyGroups; - std::unordered_set emptyGroupParents; + std::unordered_set emptyGroupParents; // groups who have had children removed, either items or empty groups. - std::unordered_set itemParents; + std::unordered_set itemParents; std::unordered_set itemsToRemove; for( EDA_ITEM* item : selection ) @@ -2211,7 +2211,9 @@ void BOARD::GroupRemoveItems( const PCBNEW_SELECTION& selection, BOARD_COMMIT* c { if( ( itemsToRemove.find( grpItem ) == itemsToRemove.end() ) && ( emptyGroups.find( grpItem ) == emptyGroups.end() ) ) + { allRemoved = false; + } } if( allRemoved ) @@ -2236,7 +2238,7 @@ void BOARD::GroupRemoveItems( const PCBNEW_SELECTION& selection, BOARD_COMMIT* c if( emptyGroups.find( grp ) == emptyGroups.end() ) { commit->Modify( grp ); - ITEM_SET members = grp->GetItems(); + BOARD_ITEM_SET members = grp->GetItems(); bool removedSomething = false; for( BOARD_ITEM* member : members ) @@ -2248,13 +2250,11 @@ void BOARD::GroupRemoveItems( const PCBNEW_SELECTION& selection, BOARD_COMMIT* c removedSomething = true; } } + wxCHECK_RET( removedSomething, "Item to be removed not found in it's parent group" ); } } for( BOARD_ITEM* grp : emptyGroups ) - { commit->Remove( grp ); - } } -