[Spice-devel] [PATCH spice-gtk 08/14] usb: remove useless device ref/unref

Uri Lublin uril at redhat.com
Mon Apr 28 05:46:14 PDT 2014


On 04/23/2014 09:09 PM, Marc-André Lureau wrote:
> A code doing an unref() on an object just before manipulating it looks
> horribly suspicious...

Suspicious indeed.

But probably it's better to move the unref below instead of removing the 
ref/unref (see below).

A device is ref'ed when install/uninstall starts and is unref'ed when 
install/uninstall finishes.

Possibly during install the ref is not needed (as there is another ref 
for the redir operation),
but I think it is needed during uninstall.

Thanks,
     Uri.

-----

diff --git a/gtk/usb-device-manager.c b/gtk/usb-device-manager.c
index 1051d10..d8bfdd8 100644
--- a/gtk/usb-device-manager.c
+++ b/gtk/usb-device-manager.c
@@ -1105,8 +1105,6 @@ static void 
spice_usb_device_manager_drv_install_cb(GObject *gobject,

      status = spice_win_usb_driver_install_finish(installer, res, &err);

-    spice_usb_device_unref(device);
-
      if (is_install) {
          spice_usb_device_set_state(device, 
SPICE_USB_DEVICE_STATE_INSTALLED);
      } else {
@@ -1122,6 +1120,8 @@ static void 
spice_usb_device_manager_drv_install_cb(GObject *gobject,
          g_warning("failed to %s win usb driver (status=0)", opstr);
      }

+    spice_usb_device_unref(device);
+
      if (! is_install) {
          return;
      }



More information about the Spice-devel mailing list