[virt-tools-list] [PATCH virt-manager 3/3] console: prevent access to deleted objects

Giuseppe Scrivano gscrivan at redhat.com
Tue Jul 1 13:36:43 UTC 2014


last commits revealed that some objects can still be accessed by
registered callbacks after the console is closed.  Unregister these
callbacks.

Signed-off-by: Giuseppe Scrivano <gscrivan at redhat.com>
---
 virtManager/console.py | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/virtManager/console.py b/virtManager/console.py
index 069925d..8f828df 100644
--- a/virtManager/console.py
+++ b/virtManager/console.py
@@ -570,6 +570,7 @@ class SpiceViewer(Viewer):
         self.display = None
         self.audio = None
         self.main_channel = None
+        self._main_channel_hids = []
         self.display_channel = None
         self.usbdev_manager = None
 
@@ -634,6 +635,11 @@ class SpiceViewer(Viewer):
             self.display.destroy()
         self.display = None
         self.display_channel = None
+
+        for i in self._main_channel_hids:
+            self.main_channel.handler_disconnect(i)
+        self._main_channel_hids = []
+
         self.main_channel = None
         self.usbdev_manager = None
 
@@ -680,10 +686,12 @@ class SpiceViewer(Viewer):
             if self.console.tunnels:
                 self.console.tunnels.unlock()
             self.main_channel = channel
-            self.main_channel.connect_after("channel-event",
+            hid = self.main_channel.connect_after("channel-event",
                 self._main_channel_event_cb)
-            self.main_channel.connect_after("notify::agent-connected",
+            self._main_channel_hids.append(hid)
+            hid = self.main_channel.connect_after("notify::agent-connected",
                 self._agent_connected_cb)
+            self._main_channel_hids.append(hid)
 
         elif (type(channel) == SpiceClientGLib.DisplayChannel and
             not self.display):
-- 
1.9.3




More information about the virt-tools-list mailing list