bugfix: On Windows, sometimes the the wrong line in the service discovery list control is updated when multiple services are displayed and a new service is discovered. cherry-pick
authorb.taylor@willowglen.ca
Wed, 12 Aug 2009 13:43:58 -0600
branchcherry-pick
changeset 374 8787fa8c6792
parent 373 a7f26d9f214f
child 375 b16bcfe531d7
bugfix: On Windows, sometimes the the wrong line in the service discovery list control is updated when multiple services are displayed and a new service is discovered.
discovery.py
--- a/discovery.py	Wed Aug 12 13:40:20 2009 -0600
+++ b/discovery.py	Wed Aug 12 13:43:58 2009 -0600
@@ -162,12 +162,17 @@
 
     def addService(self, zeroconf, type, name):
         info = self.zConfInstance.getServiceInfo(type, name)
+
+        svcname  = name.split(".")[0]
         typename = type.split(".")[0][1:]
+        ip       = str(socket.inet_ntoa(info.getAddress()))
+        port     = info.getPort()
+
         num_items = self.list.GetItemCount()
-        self.list.InsertStringItem(num_items, name.split(".")[0])
-        self.list.SetStringItem(num_items, 1, "%s"%typename)
-        self.list.SetStringItem(num_items, 2, "%s"%str(socket.inet_ntoa(info.getAddress())))
-        self.list.SetStringItem(num_items, 3, "%s"%info.getPort())
+        new_item = self.list.InsertStringItem(num_items, svcname)
+        self.list.SetStringItem(new_item, 1, "%s" % typename)
+        self.list.SetStringItem(new_item, 2, "%s" % ip)
+        self.list.SetStringItem(new_item, 3, "%s" % info.getPort())
 
     def CreateURI(self, connect_type, connect_address, connect_port):
         uri = "%s://%s:%s"%(connect_type, connect_address, connect_port)