Fix deletion of bus aliases on subsheets
Fixes https://gitlab.com/kicad/code/kicad/-/issues/4364
This commit is contained in:
parent
97a9f43a9f
commit
0de924ab4c
|
@ -196,10 +196,11 @@ void DIALOG_BUS_MANAGER::OnInitDialog( wxInitDialogEvent& aEvent )
|
||||||
bool DIALOG_BUS_MANAGER::TransferDataToWindow()
|
bool DIALOG_BUS_MANAGER::TransferDataToWindow()
|
||||||
{
|
{
|
||||||
m_aliases.clear();
|
m_aliases.clear();
|
||||||
|
m_screens.clear();
|
||||||
|
|
||||||
const SCH_SHEET_LIST& sheets = m_parent->Schematic().GetSheets();
|
const SCH_SHEET_LIST& sheets = m_parent->Schematic().GetSheets();
|
||||||
|
|
||||||
std::vector< std::shared_ptr< BUS_ALIAS > > original_aliases;
|
std::vector< std::shared_ptr<BUS_ALIAS> > original_aliases;
|
||||||
|
|
||||||
// collect aliases from each open sheet
|
// collect aliases from each open sheet
|
||||||
for( unsigned i = 0; i < sheets.size(); i++ )
|
for( unsigned i = 0; i < sheets.size(); i++ )
|
||||||
|
@ -215,8 +216,10 @@ bool DIALOG_BUS_MANAGER::TransferDataToWindow()
|
||||||
|
|
||||||
// clone into a temporary working set
|
// clone into a temporary working set
|
||||||
int idx = 0;
|
int idx = 0;
|
||||||
for( const auto& alias : original_aliases )
|
|
||||||
|
for( const std::shared_ptr<BUS_ALIAS>& alias : original_aliases )
|
||||||
{
|
{
|
||||||
|
m_screens.insert( alias->GetParent() );
|
||||||
m_aliases.push_back( alias->Clone() );
|
m_aliases.push_back( alias->Clone() );
|
||||||
auto text = getAliasDisplayText( alias );
|
auto text = getAliasDisplayText( alias );
|
||||||
m_bus_list_view->InsertItem( idx, text );
|
m_bus_list_view->InsertItem( idx, text );
|
||||||
|
@ -248,25 +251,11 @@ void DIALOG_BUS_MANAGER::OnCancelClick( wxCommandEvent& aEvent )
|
||||||
|
|
||||||
bool DIALOG_BUS_MANAGER::TransferDataFromWindow()
|
bool DIALOG_BUS_MANAGER::TransferDataFromWindow()
|
||||||
{
|
{
|
||||||
// Since we have a clone of all the data, and it is from potentially
|
for( SCH_SCREEN* screen : m_screens )
|
||||||
// multiple screens, the way this works is to rebuild each screen's aliases.
|
screen->ClearBusAliases();
|
||||||
// A list of screens is stored here so that the screen's alias list is only
|
|
||||||
// cleared once.
|
|
||||||
|
|
||||||
std::unordered_set< SCH_SCREEN* > cleared_list;
|
for( const std::shared_ptr<BUS_ALIAS>& alias : m_aliases )
|
||||||
|
alias->GetParent()->AddBusAlias( alias );
|
||||||
for( const auto& alias : m_aliases )
|
|
||||||
{
|
|
||||||
auto screen = alias->GetParent();
|
|
||||||
|
|
||||||
if( cleared_list.count( screen ) == 0 )
|
|
||||||
{
|
|
||||||
screen->ClearBusAliases();
|
|
||||||
cleared_list.insert( screen );
|
|
||||||
}
|
|
||||||
|
|
||||||
screen->AddBusAlias( alias );
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,6 +79,8 @@ private:
|
||||||
|
|
||||||
std::vector< std::shared_ptr< BUS_ALIAS > > m_aliases;
|
std::vector< std::shared_ptr< BUS_ALIAS > > m_aliases;
|
||||||
|
|
||||||
|
std::unordered_set<SCH_SCREEN*> m_screens;
|
||||||
|
|
||||||
std::shared_ptr< BUS_ALIAS > m_active_alias;
|
std::shared_ptr< BUS_ALIAS > m_active_alias;
|
||||||
|
|
||||||
DECLARE_EVENT_TABLE()
|
DECLARE_EVENT_TABLE()
|
||||||
|
|
Loading…
Reference in New Issue