From 41e06e9e9c153d4231422391f6d48d38a8f645bd Mon Sep 17 00:00:00 2001 From: dmiller Date: Sun, 31 May 2015 02:47:26 +0000 Subject: [PATCH] Fix saving of host comments in Zenmap. Fixes #133 Sometimes (all the time?) hosts are "cloned" or deep-copied instead of being copied by reference, so testing whether a host is "in" a scan is insufficient. Now we check by address, the same way that Zenmap uses to determine 2 hosts are the "same" for merging their output. Also, avoid considering a scan as having unsaved changes if the comment field is merely focused but unchanged. --- zenmap/zenmapGUI/ScanInterface.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/zenmap/zenmapGUI/ScanInterface.py b/zenmap/zenmapGUI/ScanInterface.py index 6cb4df9c4..6f3572b66 100644 --- a/zenmap/zenmapGUI/ScanInterface.py +++ b/zenmap/zenmapGUI/ScanInterface.py @@ -831,12 +831,18 @@ class ScanInterface(HIGVBox): """Sets the comment on a host from the contents of the comment text entry.""" buff = widget.get_buffer() - host.comment = buff.get_text( + comment = buff.get_text( buff.get_start_iter(), buff.get_end_iter()) + if host.comment == comment: + # no change, ignore + return + host.comment = comment for scan in self.inventory.get_scans(): - if host in scan.get_hosts(): - scan.unsaved = True - break + for h in scan.get_hosts(): + if h.get_ip() == host.get_ip() and h.get_ipv6() == host.get_ipv6(): + h.set_comment(host.comment) + scan.unsaved = True + break def build_host_details(self, hosts): """Builds and returns a list of "Host Details" pages corresponding to