[virt-tools-list] [PATCH virt-viewer 1/9] spice: use virt_viewer_signal_connect_object

Christophe Fergeau cfergeau at redhat.com
Fri Nov 14 10:53:06 UTC 2014


Hey,

On Thu, Nov 13, 2014 at 06:20:37PM +0100, Marc-André Lureau wrote:
> This isn't required, but makes it easier to track reference issues, as
> you have guarantee that callbacks won't be executed if the objects are
> disposed.
> ---
>  src/virt-viewer-session-spice.c | 51 ++++++++++++++++++++++-------------------
>  1 file changed, 28 insertions(+), 23 deletions(-)
> 
> diff --git a/src/virt-viewer-session-spice.c b/src/virt-viewer-session-spice.c
> index e28fb40..2eb2224 100644
> --- a/src/virt-viewer-session-spice.c
> +++ b/src/virt-viewer-session-spice.c
> @@ -634,13 +634,13 @@ virt_viewer_session_spice_usb_device_selection(VirtViewerSession *session,
>  
>      usb_device_widget = spice_usb_device_widget_new(priv->session,
>                                                      "%s %s");
> -    g_signal_connect(usb_device_widget, "connect-failed",
> -                     G_CALLBACK(usb_connect_failed), self);
> +    virt_viewer_signal_connect_object(usb_device_widget, "connect-failed",
> +                     G_CALLBACK(usb_connect_failed), self, 0);
>      gtk_box_pack_start(GTK_BOX(area), usb_device_widget, TRUE, TRUE, 0);
>  
>      /* This shrinks the dialog when USB devices are unplugged */
> -    g_signal_connect(usb_device_widget, "remove",
> -                     G_CALLBACK(remove_cb), dialog);
> +    virt_viewer_signal_connect_object(usb_device_widget, "remove",
> +                     G_CALLBACK(remove_cb), dialog, 0);

Indentation is odd here,

>  
>      /* show and run */
>      gtk_widget_show_all(dialog);
> @@ -738,8 +738,8 @@ virt_viewer_session_spice_channel_new(SpiceSession *s,
>  
>      g_return_if_fail(self != NULL);
>  
> -    g_signal_connect(channel, "open-fd",
> -                     G_CALLBACK(virt_viewer_session_spice_channel_open_fd_request), self);
> +    virt_viewer_signal_connect_object(channel, "open-fd",
> +                     G_CALLBACK(virt_viewer_session_spice_channel_open_fd_request), self, 0);
>  

here too


>      g_object_get(channel, "channel-id", &id, NULL);
>  
> @@ -750,22 +750,23 @@ virt_viewer_session_spice_channel_new(SpiceSession *s,
>              g_signal_handlers_disconnect_by_func(self->priv->main_channel,
>                                                   virt_viewer_session_spice_main_channel_event, self);
>  
> -        g_signal_connect(channel, "channel-event",
> -                         G_CALLBACK(virt_viewer_session_spice_main_channel_event), self);
> +        virt_viewer_signal_connect_object(channel, "channel-event",
> +                         G_CALLBACK(virt_viewer_session_spice_main_channel_event), self, 0);

Indentation again

>          self->priv->main_channel = SPICE_MAIN_CHANNEL(channel);
>          g_object_set(G_OBJECT(channel),
>                       "disable-display-position", FALSE,
>                       "disable-display-align", TRUE,
>                       NULL);
>  
> -        g_signal_connect(channel, "notify::agent-connected", G_CALLBACK(agent_connected_changed), self);
> +        virt_viewer_signal_connect_object(channel, "notify::agent-connected",
> +                                            G_CALLBACK(agent_connected_changed), self, 0);

Ditto

>      }
>  
>      if (SPICE_IS_DISPLAY_CHANNEL(channel)) {
>          g_signal_emit_by_name(session, "session-initialized");
>  
> -        g_signal_connect(channel, "notify::monitors",
> -                         G_CALLBACK(virt_viewer_session_spice_display_monitors), self);
> +        virt_viewer_signal_connect_object(channel, "notify::monitors",
> +                         G_CALLBACK(virt_viewer_session_spice_display_monitors), self, 0);

Indentation

>  
>          spice_channel_connect(channel);
>      }

ACK to the patch apart from these cosmetic issues. There are still
dozens of calls to g_signal_connect in the codebase after this patch,
why are these special?

Christophe

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/virt-tools-list/attachments/20141114/01408579/attachment.sig>


More information about the virt-tools-list mailing list