From e5f56e2fdd13c45d40356db683bf18f693e8e9e8 Mon Sep 17 00:00:00 2001 From: Calum Lind Date: Sun, 30 Sep 2012 18:23:51 +0100 Subject: [PATCH] Fix #2171 : Add Peer dialog stops responding if empty or invalid values entered --- deluge/ui/gtkui/peers_tab.py | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/deluge/ui/gtkui/peers_tab.py b/deluge/ui/gtkui/peers_tab.py index 6b2cf9a48..1df379e90 100644 --- a/deluge/ui/gtkui/peers_tab.py +++ b/deluge/ui/gtkui/peers_tab.py @@ -386,16 +386,17 @@ class PeersTab(Tab): response = peer_dialog.run() if response: value = txt_ip.get_text() - if ']' in value: - #ipv6 - ip = value.split("]")[0][1:] - port = value.split("]")[1][1:] - else: - #ipv4 - ip = value.split(":")[0] - port = value.split(":")[1] - if deluge.common.is_ip(ip): - log.debug("adding peer %s to %s", value, self.torrent_id) - client.core.connect_peer(self.torrent_id, ip, port) + if value and ':' in value: + if ']' in value: + #ipv6 + ip = value.split("]")[0][1:] + port = value.split("]")[1][1:] + else: + #ipv4 + ip = value.split(":")[0] + port = value.split(":")[1] + if deluge.common.is_ip(ip): + log.debug("adding peer %s to %s", value, self.torrent_id) + client.core.connect_peer(self.torrent_id, ip, port) peer_dialog.destroy() return True