pygui: avoid issue when joining opened xml that has a node with no ip4 address
This commit is contained in:
parent
39fd11efb3
commit
9ed42cfba8
1 changed files with 7 additions and 2 deletions
|
@ -12,7 +12,9 @@ if TYPE_CHECKING:
|
|||
from core.gui.graph.node import CanvasNode
|
||||
|
||||
|
||||
def get_index(interface: "core_pb2.Interface") -> int:
|
||||
def get_index(interface: "core_pb2.Interface") -> Optional[int]:
|
||||
if not interface.ip4:
|
||||
return None
|
||||
net = netaddr.IPNetwork(f"{interface.ip4}/{interface.ip4mask}")
|
||||
ip_value = net.value
|
||||
cidr_value = net.cidr.value
|
||||
|
@ -108,6 +110,7 @@ class InterfaceManager:
|
|||
self.used_subnets.pop(subnets.key(), None)
|
||||
else:
|
||||
index = get_index(interface)
|
||||
if index is not None:
|
||||
subnets.used_indexes.discard(index)
|
||||
self.current_subnets = None
|
||||
|
||||
|
@ -123,6 +126,8 @@ class InterfaceManager:
|
|||
for interface in interfaces:
|
||||
subnets = self.get_subnets(interface)
|
||||
index = get_index(interface)
|
||||
if index is None:
|
||||
continue
|
||||
subnets.used_indexes.add(index)
|
||||
if subnets.key() not in self.used_subnets:
|
||||
self.used_subnets[subnets.key()] = subnets
|
||||
|
|
Loading…
Reference in a new issue