From 9a39de0ec2623ff018392f175870d84dd0277702 Mon Sep 17 00:00:00 2001 From: KV Date: Tue, 28 Dec 2021 19:04:28 +0100 Subject: [PATCH] Make sure loop connected pins are not hidden (#264) - Resolves #263 that describes warnings and weird loop drawing because loop connected pins are hidden when hide_disconnected_pins=True. - Activate loop pins as early as possible to enable correct counting of connected pins when connector.additional_components.qty_multiplier=populated. - Check that loop pins actually exist before activating them. --- docs/CHANGELOG.md | 2 +- src/wireviz/DataClasses.py | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 680c4fc6..a7932ad1 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -17,7 +17,7 @@ ### Misc. fixes - Use `isort` and `black` for cleaner code and easier merging ([#248](https://github.com/wireviz/WireViz/pull/248)) - Code improvements ([#246](https://github.com/wireviz/WireViz/pull/246), [#250](https://github.com/wireviz/WireViz/pull/250)) -- Bug fix ([#318](https://github.com/wireviz/WireViz/pull/318)) +- Bug fixes ([#264](https://github.com/wireviz/WireViz/pull/264), [#318](https://github.com/wireviz/WireViz/pull/318)) ## [0.3.2](https://github.com/formatc1702/WireViz/tree/v0.3.2) (2021-11-27) diff --git a/src/wireviz/DataClasses.py b/src/wireviz/DataClasses.py index 523630b7..15693aa1 100644 --- a/src/wireviz/DataClasses.py +++ b/src/wireviz/DataClasses.py @@ -204,11 +204,16 @@ def __post_init__(self) -> None: self.show_pincount = self.style != "simple" for loop in self.loops: - # TODO: check that pins to connect actually exist # TODO: allow using pin labels in addition to pin numbers, just like when defining regular connections # TODO: include properties of wire used to create the loop if len(loop) != 2: raise Exception("Loops must be between exactly two pins!") + for pin in loop: + if pin not in self.pins: + raise Exception(f'Unknown loop pin "{pin}" for connector "{self.name}"!') + # Resolve https://github.com/formatc1702/WireViz/issues/263 + # Make sure loop connected pins are not hidden. + self.activate_pin(pin) for i, item in enumerate(self.additional_components): if isinstance(item, dict):