Received: from eggs.gnu.org ([2001:4830:134:3::10]:39069) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YmjFn-00072T-CO for qemu-devel@nongnu.org; Mon, 27 Apr 2015 09:39:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YmjFi-0006Fd-CW for qemu-devel@nongnu.org; Mon, 27 Apr 2015 09:39:19 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47197) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YmjFi-0006FL-3l for qemu-devel@nongnu.org; Mon, 27 Apr 2015 09:39:14 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t3RDdC8Y013449 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Mon, 27 Apr 2015 09:39:13 -0400 From: Gerd Hoffmann Date: Mon, 27 Apr 2015 15:39:04 +0200 Message-Id: <1430141948-18272-2-git-send-email-kraxel@redhat.com> In-Reply-To: <1430141948-18272-1-git-send-email-kraxel@redhat.com> References: <1430141948-18272-1-git-send-email-kraxel@redhat.com> Subject: [Qemu-devel] [PULL 1/5] gtk: handle switch_surface(NULL) properly List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Gerd Hoffmann Signed-off-by: Gerd Hoffmann --- ui/gtk.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/ui/gtk.c b/ui/gtk.c index 51abac9..bcbf51a 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -363,6 +363,9 @@ static void gd_update_geometry_hints(VirtualConsole *vc) GtkWindow *geo_window; if (vc->type == GD_VC_GFX) { + if (!vc->gfx.ds) { + return; + } if (s->free_scale) { geo.min_width = surface_width(vc->gfx.ds) * VC_SCALE_MIN; geo.min_height = surface_height(vc->gfx.ds) * VC_SCALE_MIN; @@ -574,22 +577,28 @@ static void gd_switch(DisplayChangeListener *dcl, VirtualConsole *vc = container_of(dcl, VirtualConsole, gfx.dcl); bool resized = true; - trace_gd_switch(vc->label, surface_width(surface), surface_height(surface)); + trace_gd_switch(vc->label, + surface ? surface_width(surface) : 0, + surface ? surface_height(surface) : 0); if (vc->gfx.surface) { cairo_surface_destroy(vc->gfx.surface); + vc->gfx.surface = NULL; + } + if (vc->gfx.convert) { + pixman_image_unref(vc->gfx.convert); + vc->gfx.convert = NULL; } - if (vc->gfx.ds && + if (vc->gfx.ds && surface && surface_width(vc->gfx.ds) == surface_width(surface) && surface_height(vc->gfx.ds) == surface_height(surface)) { resized = false; } vc->gfx.ds = surface; - if (vc->gfx.convert) { - pixman_image_unref(vc->gfx.convert); - vc->gfx.convert = NULL; + if (!surface) { + return; } if (surface->format == PIXMAN_x8r8g8b8) { @@ -690,6 +699,9 @@ static gboolean gd_draw_event(GtkWidget *widget, cairo_t *cr, void *opaque) if (!gtk_widget_get_realized(widget)) { return FALSE; } + if (!vc->gfx.ds) { + return FALSE; + } fbw = surface_width(vc->gfx.ds); fbh = surface_height(vc->gfx.ds); @@ -771,6 +783,10 @@ static gboolean gd_motion_event(GtkWidget *widget, GdkEventMotion *motion, int fbh, fbw; int ww, wh; + if (!vc->gfx.ds) { + return TRUE; + } + fbw = surface_width(vc->gfx.ds) * vc->gfx.scale_x; fbh = surface_height(vc->gfx.ds) * vc->gfx.scale_y; -- 1.8.3.1