Skip to content

Commit

Permalink
Block: don't crash when deleting one leg of a diffpair and saving
Browse files Browse the repository at this point in the history
changelog: Bugfixes/Schematic editor: don't crash when deleting one leg of a diffpair and saving
  • Loading branch information
carrotIndustries committed Aug 27, 2022
1 parent e81e71e commit fd624da
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
7 changes: 5 additions & 2 deletions src/block/block.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,13 @@ void Block::update_diffpairs()
}
for (auto &it : nets) {
if (it.second.diffpair_primary) {
if (nets.count(it.second.diffpair.uuid))
if (nets.count(it.second.diffpair.uuid)) {
it.second.diffpair->diffpair = &it.second;
else
}
else {
it.second.diffpair = nullptr;
it.second.diffpair_primary = false;
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/block/net.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ json Net::serialize() const
j["net_class"] = net_class->uuid;
j["power_symbol_name_visible"] = power_symbol_name_visible;
j["power_symbol_style"] = power_symbol_style_lut.lookup_reverse(power_symbol_style);
if (diffpair_primary)
if (diffpair_primary && diffpair)
j["diffpair"] = diffpair->uuid;
j["is_port"] = is_port;
j["port_direction"] = Pin::direction_lut.lookup_reverse(port_direction);
Expand Down
2 changes: 1 addition & 1 deletion src/router/pns_horizon_iface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ bool PNS_HORIZON_RULE_RESOLVER::DpNetPair(const PNS::ITEM *aItem, int &aNetP, in
return false;
auto net = m_iface->get_net_for_code(aItem->Net());
if (net->diffpair) {
if (net->diffpair_primary) {
if (net->diffpair_primary && net->diffpair) {
aNetP = m_iface->get_net_code(net->uuid);
aNetN = m_iface->get_net_code(net->diffpair->uuid);
}
Expand Down

0 comments on commit fd624da

Please sign in to comment.