[virt-tools-list] [PATCH 2/3] virt-viewer-window: Don't use priv->display when it is NULL

Christophe Fergeau cfergeau at redhat.com
Thu Mar 21 14:04:33 UTC 2013


ACK, was too lazy to audit these places in my easy version of this series
;)

Christophe
On Thu, Mar 21, 2013 at 01:37:00PM +0100, Hans de Goede wrote:
> Add some missing checks for not having a display. Note that where
> functions should not be called (ie menu items should be disabled) I've
> used g_return_if_fail.
> 
> Signed-off-by: Hans de Goede <hdegoede at redhat.com>
> ---
>  src/virt-viewer-window.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/src/virt-viewer-window.c b/src/virt-viewer-window.c
> index 80ba322..b0cf078 100644
> --- a/src/virt-viewer-window.c
> +++ b/src/virt-viewer-window.c
> @@ -594,6 +594,8 @@ virt_viewer_window_menu_send(GtkWidget *menu,
>      const char *text = gtk_label_get_label(GTK_LABEL(label));
>      VirtViewerWindowPrivate *priv = self->priv;
>  
> +    g_return_if_fail(priv->display != NULL);
> +
>      for (i = 0 ; i < G_N_ELEMENTS(keyCombos) ; i++) {
>          if (!strcmp(text, keyCombos[i].label)) {
>              DEBUG_LOG("Sending key combo %s", gtk_label_get_text(GTK_LABEL(label)));
> @@ -768,7 +770,8 @@ virt_viewer_window_menu_view_resize(GtkWidget *menu,
>          priv->auto_resize = FALSE;
>      }
>  
> -    virt_viewer_display_set_auto_resize(priv->display, priv->auto_resize);
> +    if (priv->display)
> +        virt_viewer_display_set_auto_resize(priv->display, priv->auto_resize);
>  }
>  
>  static void add_if_writable (GdkPixbufFormat *data, GHashTable *formats)
> @@ -903,6 +906,7 @@ G_MODULE_EXPORT void
>  virt_viewer_window_menu_view_release_cursor(GtkWidget *menu G_GNUC_UNUSED,
>                                              VirtViewerWindow *self)
>  {
> +    g_return_if_fail(self->priv->display != NULL);
>      virt_viewer_display_release_cursor(VIRT_VIEWER_DISPLAY(self->priv->display));
>  }
>  
> -- 
> 1.8.1.4
> 
> _______________________________________________
> virt-tools-list mailing list
> virt-tools-list at redhat.com
> https://www.redhat.com/mailman/listinfo/virt-tools-list
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/virt-tools-list/attachments/20130321/32547a0f/attachment.sig>


More information about the virt-tools-list mailing list